简体   繁体   English

python:如何根据 x 轴上的元素数量调整 plotly plot 宽度

[英]python: How to adjust plotly plot width on the basis of number of elements in x-axis

I am trying to plot a graph on dash with a dropdown with date on x-axis and Release on y-axis like a Roadmap, so if a user selects his desired "Release", the graph will be updated.我正在尝试 plot 破折号上的图表,在 x 轴上带有日期的下拉菜单,在 y 轴上像路线图一样发布,所以如果用户选择他想要的“发布”,图表将被更新。 My problem is, when there are a huge number of "Dates", the graph looks something like this:我的问题是,当有大量“日期”时,图表看起来像这样: 在此处输入图像描述

My questions are:我的问题是:

  1. How can I say that if the amount of values on x-axis is greater than a particular number, increase the plot width to for eg.我怎么能说如果 x 轴上的值大于特定数字,则将 plot 宽度增加到例如。 2000 and keep the default width=1000. 2000 并保持默认宽度 = 1000。

    style={'overflowY': 'scroll', 'width': 1000}样式={'overflowY': '滚动', '宽度': 1000}

    fig.update_layout( autosize=False, width=1000, height=400) fig.update_layout(autosize=False, width=1000, height=400)

  2. what can I do so that the text on scatter points don't overlap each other to avoid overcrowding?我该怎么做才能使散点上的文本不会相互重叠以避免过度拥挤?

  3. In some cases, there are multiple y-axis value for an individual x-axis (Date) value, due to which the plot just takes 1 point on x axis and puts all the values of y-axis there:在某些情况下,单个 x 轴(日期)值有多个 y 轴值,因此 plot 仅在 x 轴上取 1 个点并将 y 轴的所有值放在那里:

在此处输入图像描述

for question 2 (what can I do so that the text on scatter points don't overlap each other to avoid overcrowding?) use turtle.Pen(write, size(your size))(DATE) you will need to change the DATE to the date you want but it will still work对于问题 2(我该怎么做才能使散点上的文本不会相互重叠以避免过度拥挤?)使用 turtle.Pen(write, size(your size))(DATE) 您需要将 DATE 更改为你想要的日期,但它仍然有效

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM