英文:
Is it possible to have a y-axis with uneven intervals/ticks, but have it evenly spaced on plotly?
问题
我有一个图表,由不同程序创建,我正在尝试使用Python中的Plotly重新创建。我主要的问题是在y轴上,大多数百分比都是以10%的间隔,除了接近0%和100%的刻度。接近0%和100%的刻度都挤在一起,因为它们的值非常接近,使其难以辨认。我想保留所有的值,但希望它们的位置彼此之间间距相等。
这些是我在y轴上的值:
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]
我目前在y轴上使用以下设置:
tickformat='.2%', tickmode='array', tickvals= yTicks
更新:我已经查看了并尝试了文档中与轴和线绘制函数相关的许多看似相关的内容,但到目前为止似乎都没有起作用。如果有人也想查看它们,这是链接。https://plotly.com/python/reference/layout/yaxis/
https://plotly.com/python-api-reference/generated/plotly.express.line.html
英文:
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
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
答案1
得分: 0
显然,解决这个问题的方法是使用 graph_objects 创建 13 个子图,并使用共享的 x 轴。每个子图用于刻度之间的变化,共有 13 种独特的刻度间隔,总共有 20 个刻度间隔中的 13 个。这也意味着有 13 个 y 轴,我也对其进行了布局设置。这似乎在我之前使用的 plotly express 中是不可能实现的。我不得不使用 plotly 的较低级版本。
英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论