title: Plotly: How to prevent varying thickness of bars in a Gantt diagram?
body: <p>I'm trying to make a <code>plotly</code> <a href="https://plotly.com/python/gantt/" rel="nofollow noreferrer">Gantt</a> diagram using <code>plotly.express</code> as in the example, but <code>plotly</code> is somehow varying the bar thickness based on the given names (see picture, red &gt; green &gt; blue):</p>
  <p><a href="https://i.stack.imgur.com/dLXCF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dLXCF.png" alt="enter image description here" /></a></p>
  <p>The code looks like this:</p>
  <pre class="lang-py prettyprint-override"><code>import pandas as pd
  import plotly.express as px
  
  df = pd.read_csv('stackoverflow.csv')
  fig = px.timeline(df, x_start=&quot;Start&quot;, x_end=&quot;Finish&quot;, y=&quot;Task&quot;, color=&quot;Resource&quot;, text=&quot;Task&quot;, width=1600, height=800)
  fig.update_yaxes(autorange=&quot;reversed&quot;)
  fig.update_xaxes(
      dtick=&quot;1000&quot;,
      tickformat=&quot;%M:%S&quot;,
      ticklabelmode=&quot;instant&quot;)
  fig.update_layout(xaxis_range=[df.Start.min(), df.Finish.max()])
  fig.show()
  </code></pre>
  <p>With <code>stackoverflow.csv</code> being:</p>
  <pre><code>Task,Start,Finish,Workstation,Resource
  1,1970-01-01 01:00:00.000,1970-01-01 01:00:05.400,1,ABL
  2,1970-01-01 01:00:00.000,1970-01-01 01:00:01.300,2,ABS
  3,1970-01-01 01:00:00.000,1970-01-01 01:00:01.000,3,ABU
  4,1970-01-01 01:00:00.000,1970-01-01 01:00:02.000,4,ACC
  5,1970-01-01 01:00:02.000,1970-01-01 01:00:03.300,4,ACC
  6,1970-01-01 01:00:03.300,1970-01-01 01:00:05.300,4,ACC
  7,1970-01-01 01:00:00.000,1970-01-01 01:00:01.300,5,ABS
  8,1970-01-01 01:00:00.000,1970-01-01 01:00:01.000,6,ACT
  9,1970-01-01 01:00:00.000,1970-01-01 01:00:02.000,7,ACC
  10,1970-01-01 01:00:02.000,1970-01-01 01:00:03.300,7,ACC
  11,1970-01-01 01:00:03.300,1970-01-01 01:00:05.300,7,ACC
  12,1970-01-01 01:00:00.000,1970-01-01 01:00:01.300,8,ABS
  13,1970-01-01 01:00:00.000,1970-01-01 01:00:01.000,9,ABU
  14,1970-01-01 01:00:00.000,1970-01-01 01:00:01.300,10,ACC
  15,1970-01-01 01:00:00.000,1970-01-01 01:00:01.300,11,ABS
  16,1970-01-01 01:00:00.000,1970-01-01 01:00:01.000,12,ABU
  17,1970-01-01 01:00:00.000,1970-01-01 01:00:01.300,13,ACC
  18,1970-01-01 01:00:01.300,1970-01-01 01:00:03.300,13,ACC
  19,1970-01-01 01:00:00.000,1970-01-01 01:00:01.300,14,ABS
  20,1970-01-01 01:00:00.000,1970-01-01 01:00:01.000,15,ABP
  21,1970-01-01 01:00:00.000,1970-01-01 01:00:01.500,16,ABZ
  22,1970-01-01 01:00:00.000,1970-01-01 01:00:01.300,17,ACC
  23,1970-01-01 01:00:01.300,1970-01-01 01:00:03.300,17,ACC
  24,1970-01-01 01:00:00.000,1970-01-01 01:00:01.300,18,ABS
  25,1970-01-01 01:00:00.000,1970-01-01 01:00:01.000,19,AAW
  26,1970-01-01 01:00:00.000,1970-01-01 01:00:02.000,20,ACC
  27,1970-01-01 01:00:02.000,1970-01-01 01:00:03.300,20,ACC
  28,1970-01-01 01:00:00.000,1970-01-01 01:00:01.300,21,ABS
  29,1970-01-01 01:00:00.000,1970-01-01 01:00:01.000,22,ABU
  30,1970-01-01 01:00:00.000,1970-01-01 01:00:01.300,23,ACC
  </code></pre>
  <p>I want all the bars to be of the same thickness, surprisingly this works when I change the names of the <code>Resource</code> to some random 3-char value:
  <a href="https://i.stack.imgur.com/2lO6O.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2lO6O.png" alt="enter image description here" /></a></p>
  <p>I think it has to do with the resources starting with <code>AB*</code> or <code>AC*</code>. Unfortunately, the names of the resources depend on real-world names, so I cannot arbitrarily change them. The varying bar thickness happens as well when the name of the resource is something like <code>FooBar-Axx-FOO</code> with <code>xx = [CC, BS, CT...]</code>. Does anyone know why this is happening or how to prevent it?</p>
  <p>P.S.: The</p>
  <pre><code>fig.update_xaxes(
      dtick=&quot;1000&quot;,
      tickformat=&quot;%M:%S&quot;)
  </code></pre>
  <p>was necessary to show seconds in the Gantt instead of days... is there a better way to achieve this?</p>
  <hr />
  <p><strong>Update</strong>:
  <code>conda</code> environment yaml file I'm using to create the problem:</p>
  <pre class="lang-yaml prettyprint-override"><code>name: stack
  channels:
    - conda-forge
    - pytorch
    - plotly
  dependencies:
      - python&gt;=3.5,&lt;3.8
      - pandas
      - pip
      - pip:
        - plotly
  </code></pre>
  <p>slightly modified code still yielding the same problem as shown above:</p>
  <pre><code>import pandas as pd
  import plotly.express as px
  from io import StringIO
  
  
  csv = &quot;&quot;&quot;Task,Start,Finish,Workstation,Resource
  1,1970-01-01 01:00:00.000,1970-01-01 01:00:05.400,1,ABL
  2,1970-01-01 01:00:00.000,1970-01-01 01:00:01.300,2,ABS
  3,1970-01-01 01:00:00.000,1970-01-01 01:00:01.000,3,ABU
  4,1970-01-01 01:00:00.000,1970-01-01 01:00:02.000,4,ACC
  5,1970-01-01 01:00:02.000,1970-01-01 01:00:03.300,4,ACC
  6,1970-01-01 01:00:03.300,1970-01-01 01:00:05.300,4,ACC
  7,1970-01-01 01:00:00.000,1970-01-01 01:00:01.300,5,ABS
  8,1970-01-01 01:00:00.000,1970-01-01 01:00:01.000,6,ACT
  9,1970-01-01 01:00:00.000,1970-01-01 01:00:02.000,7,ACC
  10,1970-01-01 01:00:02.000,1970-01-01 01:00:03.300,7,ACC
  11,1970-01-01 01:00:03.300,1970-01-01 01:00:05.300,7,ACC
  12,1970-01-01 01:00:00.000,1970-01-01 01:00:01.300,8,ABS
  13,1970-01-01 01:00:00.000,1970-01-01 01:00:01.000,9,ABU
  14,1970-01-01 01:00:00.000,1970-01-01 01:00:01.300,10,ACC
  15,1970-01-01 01:00:00.000,1970-01-01 01:00:01.300,11,ABS
  16,1970-01-01 01:00:00.000,1970-01-01 01:00:01.000,12,ABU
  17,1970-01-01 01:00:00.000,1970-01-01 01:00:01.300,13,ACC
  18,1970-01-01 01:00:01.300,1970-01-01 01:00:03.300,13,ACC
  19,1970-01-01 01:00:00.000,1970-01-01 01:00:01.300,14,ABS
  20,1970-01-01 01:00:00.000,1970-01-01 01:00:01.000,15,ABP
  21,1970-01-01 01:00:00.000,1970-01-01 01:00:01.500,16,ABZ
  22,1970-01-01 01:00:00.000,1970-01-01 01:00:01.300,17,ACC
  23,1970-01-01 01:00:01.300,1970-01-01 01:00:03.300,17,ACC
  24,1970-01-01 01:00:00.000,1970-01-01 01:00:01.300,18,ABS
  25,1970-01-01 01:00:00.000,1970-01-01 01:00:01.000,19,AAW
  26,1970-01-01 01:00:00.000,1970-01-01 01:00:02.000,20,ACC
  27,1970-01-01 01:00:02.000,1970-01-01 01:00:03.300,20,ACC
  28,1970-01-01 01:00:00.000,1970-01-01 01:00:01.300,21,ABS
  29,1970-01-01 01:00:00.000,1970-01-01 01:00:01.000,22,ABU
  30,1970-01-01 01:00:00.000,1970-01-01 01:00:01.300,23,ACC&quot;&quot;&quot;
  
  df = pd.read_csv(StringIO(csv))
  # df = pd.read_csv(&quot;stackoverflow.csv&quot;)
  fig = px.timeline(df, x_start=&quot;Start&quot;, x_end=&quot;Finish&quot;, y=&quot;Task&quot;, color=&quot;Resource&quot;, text=&quot;Task&quot;, width=1600, height=800)
  fig.update_yaxes(autorange=&quot;reversed&quot;)
  fig.update_xaxes(
      dtick=&quot;1000&quot;,
      tickformat=&quot;%M:%S&quot;,
      ticklabelmode=&quot;instant&quot;)
  fig.update_layout(xaxis_range=[df.Start.min(), df.Finish.max()])
  fig.show()
  </code></pre>
  <p>The output of <code>conda list</code>:</p>
  <pre><code>pip                       20.2.4                     py_0    conda-forge
  plotly                    4.12.0                   pypi_0    pypi
  python                    3.7.8           h6f2ec95_1_cpython    conda-forge
  </code></pre>