pythonplotlyplotly.graph-objects

How to make bars more visible while using plotly?


I am trying to plot some data using plotly graph_objects. X axis has dates as categories and Y axis has depth values. I realized my graph becomes less visible when there is a relevant quantity of data. It almost seems that it become transparent.

I already tried to change the opacity to 1 or bargroupgap to 0, but it is still weird. See image below:

enter image description here

# Create a figure
fig = go.Figure()

# Plot bars using go.Bar
fig.add_trace(go.Bar(
    x=well_df['DATE'],  # Intervals as x-axis
    y=well_df['y_end'] - well_df['y_start'],  # Height of the bars (difference between end and start)
    base=well_df['y_start'],  # Bottom of the bars (starting at y_start)
    marker=dict(color=well_df['FILTRO'].map(color_map), opacity=1),  # Map colors for categories
    opacity=1))

# Customize layout
fig.update_layout(
    xaxis_title="DATE",
    yaxis_title="DEPTH",
    yaxis=dict(autorange="reversed"),
    barmode='group',  # Group bars by category
    bargap=0.05, # Change this value to modiffy gaps between different categories 
    bargroupgap=0,
    xaxis=dict(tickangle=45),  # Rotate values from x axis to 45°
    showlegend=False)

# Show the plot
fig.show(renderer="browser")

How can I make it to look more visible (with stronger colors)?


Solution

  • I managed to solve it by updating line width:

    fig.update_traces(marker_line_width=0)