Search code examples
pythongraphplotlyplotly-python

Is it possible to have a y-axis with uneven intervals/ticks, but have it evenly spaced on plotly?


I have a graph created by a different program that I am trying to recreate using plotly in python. The main problem I have is that for the y-axis, most of the percentages are in intervals of 10% except for the ticks near 0% and 100%. The ticks near the 0% and 100% are all squished together because they have very close values, making them illegible. I want to keep all the values, but have them positioned to have an equal spacing from each other.

These are the values I have on the y-axis: yTicks = [0,0.0010, 0.0050, 0.0100, 0.0200, 0.0500, 0.1000, 0.2000, 0.3000, 0.4000, 0.5000, 0.6000, 0.7000, 0.8000, 0.9000, 0.9500, 0.9800, 0.9900, 0.9950, 0.9990, 1]

I am currently using these settings for the y-axis: tickformat='.2%', tickmode='array', tickvals= yTicks

my plotly graph

the type of y axis I'm looking for

Update: I have looked through and tried as many relevant looking things in the documentation for the axis and the line plotting function and none seemed to work so far. In case someone wants to look at them as well, here are the links. https://plotly.com/python/reference/layout/yaxis/ https://plotly.com/python-api-reference/generated/plotly.express.line.html


Solution

  • Apparently the answer to this was to create 13 subplots using graph_objects and use a shared x axis. Each subplot is used for a change in the intervals between the tick and there were 13 unique change in intervals out of the 20 intervals. This also means there were 13 yaxes that I set the layout for as well. It doesn’t seem like this would’ve been possible with plotly express which was what I was using before. I had to use the lower level version of plotly.