Programming
How Plotly 7 Synchronizes Ticks on Overlaid Axes—and How to Preserve or Change That Behavior
Plotly 7 changes the default tick behavior for overlaid axes. Build a dual-axis figure, inspect the overlaid axis, make synchronized ticks explicit, and approach independent ticks without relying on an unverified setting.
A dual-axis chart puts two axes in one plotting area. That can be useful when two series have different units, but it also means a library’s axis defaults can affect how the chart reads.
Plotly 7 changes one of those defaults: the Plotly Python multiple-axes documentation says an axis that overlays another defaults to tickmode="sync". If an existing figure relies on the default, its overlaid axis may behave differently after an upgrade.
This tutorial builds a two-y-axis figure, identifies which axis is overlaid, makes synchronized ticks explicit, and shows how to investigate changing that behavior. The supplied documentation establishes the new sync default, but its excerpts do not establish which independent tick-mode values are accepted. So this tutorial does not guess an alternative such as auto. Instead, it shows how to check the exact reference for your installed version before changing the setting.
What sync changes—and what it does not
An overlaid axis occupies the same plotting area as another axis. In a dual-y-axis figure, for example, the primary y-axis can appear on the left and a second y-axis on the right. Plotly 7’s documented default is for the overlaid axis to use tickmode="sync".
Think of that as a rule for tick placement, not as a conversion between axes. If one axis represents revenue and the other represents a percentage, synchronized tick positions do not make dollars and percentages equivalent. Each axis still needs an accurate title and unit, and the reader still needs to understand what values belong to which series.
The configuration relationship is simple:
flowchart LR
A["Primary axis"] --> B["Shared plot area"]
C["Overlaid axis"] --> B
C -->|"tickmode sync"| A
The diagram describes the documented relationship at a high level. It does not mean that the axes share units or data ranges.
1. Build a dual-axis figure
Use graph objects to put two traces on separate y-axes in one figure. The example below places quarterly revenue on the primary axis and margin on an overlaid secondary axis. The values are illustrative; the important parts are the trace-to-axis assignments and the layout relationship.
import plotly.graph_objects as go
quarters = ["Q1", "Q2", "Q3", "Q4"]
fig = go.Figure()
fig.add_trace(
go.Bar(
x=quarters,
y=[120, 150, 135, 180],
name="Revenue",
yaxis="y",
)
)
fig.add_trace(
go.Scatter(
x=quarters,
y=[12, 15, 13, 18],
name="Margin",
yaxis="y2",
)
)
fig.update_layout(
title="Revenue and margin by quarter",
yaxis={"title": "Revenue (illustrative units)"},
yaxis2={
"title": "Margin (illustrative units)",
"overlaying": "y",
"side": "right",
},
)
fig.show()
The second trace uses yaxis="y2", and the corresponding layout axis has overlaying="y". Those fields identify the secondary axis as the one overlaid on the primary axis. That is where you will inspect or set tickmode.
Use meaningful units in a real chart. The example’s values are deliberately not presented as percentages: the source excerpts establish the tick-mode change, not any particular business interpretation of these numbers. If your data are percentages, say so in the title; do not rely on readers to infer the units from the series name.
If you already have a figure, do not rebuild it just to investigate the setting. Find the trace using the secondary axis and then find that axis’s layout entry. The multiple-axes documentation is the relevant reference for the relationship between overlaid axes and their tick mode.
2. Make synchronized ticks explicit
Plotly 7’s documented default is sync for an overlaid axis. You can state that choice directly in the layout:
fig.update_layout(
yaxis2={
"title": "Margin (illustrative units)",
"overlaying": "y",
"side": "right",
"tickmode": "sync",
}
)
This is useful when you want the figure definition to communicate its intent rather than rely on a version default. It also makes an upgrade review easier: a maintainer can see that synchronized ticks are deliberate.
Set the property on the overlaid axis. In this example, that is yaxis2, because it is the axis whose layout specifies overlaying="y". Setting a property on the primary axis instead would not express the same intent for the second axis.
You can inspect what the Python figure object contains before displaying it:
print(fig.layout.yaxis2)
print("tickmode:", fig.layout.yaxis2.tickmode)
This checks the figure’s stored layout. It does not, by itself, verify the appearance of the rendered chart. Keep the two checks separate: inspect the configuration to catch an absent or unexpected setting, then render the figure to judge whether it communicates clearly.
For a quick serialized view of the layout, you can also print the figure as JSON:
print(fig.to_json())
Use this when the figure is assembled in several places and you need to locate the final layout value. It is a debugging aid, not a substitute for the version-specific reference: a serialized value tells you what you assigned, not whether every intended value is supported by the installed release.
3. Check your installed version before changing the mode
The key question when you want independent tick placement is not just “what value looks plausible?” It is “which values does the reference for my installed Plotly version accept?” The supplied documentation excerpt identifies sync as the new default but does not list the alternatives. Therefore, do not copy an unverified mode into production code.
First check which Plotly version your environment imports:
python -c "import plotly; print(plotly.__version__)"
Then consult the Plotly Python multiple-axes documentation and the layout axis reference for that version. Confirm the accepted values for tickmode and identify the exact value that requests the independent behavior you need. The source excerpts supplied for this tutorial do not provide that value, so no independent-mode example can be responsibly filled in here.
Once you have confirmed the value in the matching reference, change only the overlaid axis’s tickmode. Keep overlaying="y" in place if you still want both axes in the same plot area. Removing the overlay would change the axis arrangement, rather than simply changing how the overlaid axis places ticks.
The setting you are validating has this shape:
fig.update_layout(
yaxis2={
"title": "Margin (illustrative units)",
"overlaying": "y",
"side": "right",
"tickmode": "<documented independent mode>",
}
)
Replace the placeholder only after checking the reference for the installed version; it is intentionally not a runnable tick-mode value. This prevents a common failure in version-sensitive chart work: treating a familiar-looking setting as supported just because it appears in an example elsewhere.
If you cannot find a version-matched reference, keep the documented sync behavior or postpone the change until you can verify the alternative. That is safer than silently shipping a configuration that may be rejected or ignored.
4. Compare the rendered result without changing other variables
Once you have a documented independent mode, compare it with sync using the same data and layout. Keep the traces, dimensions, titles, and ranges the same during the comparison; change only the secondary axis’s tick mode. Otherwise, you will not know which edit caused the visual difference.
A practical comparison procedure is:
- Save or copy the synchronized figure.
- Set the documented independent mode on the overlaid axis in the copy.
- Render both figures in the same environment and at the same size.
- Compare label placement and readability, not only the number of tick labels.
- Confirm the units and axis titles are clear in both versions.
If you keep both figures in code, make the mode an explicit function argument only after you have verified the allowed values. For example, a helper can accept the tick-mode string and use it on yaxis2; do not treat that helper as validation of the string itself. A helper that accepts arbitrary input can make a typo easier to spread through an application.
The same discipline applies when comparing a chart before and after an upgrade. Use the same data and chart dimensions, and inspect the overlaid axis first. The documented change concerns its tick-mode default, so changing trace values or axis ranges before checking that property makes diagnosis harder.
5. Diagnose a chart that changed after an upgrade
If a right-hand axis looks different after upgrading to Plotly 7, work through the layout rather than changing several chart properties at once.
Find the overlaid axis. In the example, yaxis2 has overlaying="y". In your figure, identify the layout axis that has the overlay relationship; do not assume that every chart uses the same axis numbering.
Check whether tickmode is explicit. Inspect the relevant layout entry. If it is absent, the figure may be relying on the Plotly 7 default described by the multiple-axes documentation.
Decide whether synchronization is intended. If it is, set tickmode="sync" explicitly. If it is not, consult the reference for your installed version and choose a documented independent mode.
Render before changing anything else. Compare the result in the environment where the chart is actually used. A layout inspection can confirm the configured property, but it cannot tell you whether the chart is legible in a dashboard or at a particular display size.
Recheck labels and units. A tick-mode change does not explain the relationship between two different measurements. Make the axes clear even if the tick positions look orderly.
flowchart TD
A["Find overlaid axis"] --> B["Inspect tickmode"]
B --> C["Keep sync explicitly"]
B --> D["Verify independent mode"]
C --> E["Render and review"]
D --> E
This is a troubleshooting sequence, not a claim that either choice is universally better. The choice depends on the chart’s purpose and the behavior documented for the Plotly version in use.
6. Preserve intent across upgrades
An older figure can rely on a default without recording that decision in its layout. Plotly’s multiple-axes documentation specifically marks the sync default as changed in version 7. When upgrading, find axes with overlaying and decide whether the new default is appropriate for each figure.
For important charts, make the intended mode explicit when it is supported by the version you deploy. Keep the version visible in your dependency configuration, and review rendered output when that version changes. A small visual regression check is valuable because a Python-level assertion can confirm that a layout value was assigned, but it cannot establish whether the finished chart remains understandable.
Use a checklist during review:
- Which layout axis has
overlayingset? - Does that axis explicitly specify
tickmode? - Is the selected value documented for the installed version?
- Are both axes titled with clear units?
- Does the chart remain legible at its actual display size?
- Does the second axis help explain the data, or only make two unrelated trends appear visually comparable?
When to keep or change synchronized ticks
Keep synchronized ticks when that placement suits the purpose of the figure and the result remains readable. Change the behavior only after confirming the independent mode in the version-specific reference and comparing the rendered result.
Whichever mode you choose, do not treat visual alignment as a mathematical relationship. A shared position on the plot does not make different units equal. Clear labels and a deliberate explanation of the two scales matter more than making the tick marks look tidy.
The concrete Plotly 7 change is narrow: an axis that overlays another now defaults to tickmode="sync", according to the supplied Python multiple-axes documentation. To preserve that behavior, set tickmode="sync" on the overlaid axis explicitly. To change it, verify the accepted independent value for your installed release, apply it to that same axis, and compare the rendered chart. That gives you a version-aware fix without guessing at an unsupported setting.