Bar graph colors are too dark/dim

I am making plotly.express graphs in a Jupyter Notebook. I have been able to make a histogram plot with a dark theme that looks alright:

Hereโ€™s the code I used for making the Histogram

# Use plotly to make it interactive
fig = px.histogram(
        data_frame=df, 
        x='Score', 
        color='Score',
        color_discrete_sequence=px.colors.qualitative.Set3,
        opacity=0.7,  # Transparency of bars
        title='Food Review Counts by Ratings',
        labels={'Score': 'Rating'},  # Axis labels
        template='plotly_dark',  # Dark theme
)

# Adjust layout for better appearance
fig.update_layout(
    bargap=0.2,  # Gap between bars
    xaxis=dict(tickmode='linear'),  # Linear tick marks on x-axis
    yaxis=dict(title='Counts'),
    showlegend=True
)

# Show the plot
fig.show()

Now when I try to make a bar graph, the colors seem to be too dark/dim

This is the code I used for making the bar graph:

# Make an interactive bar chart
fig = px.bar(data_frame=vaders, x='Score', y='compound',
             title='Compound Score by Ratings',
             labels={'Score': 'Rating'},
             color='Score',
             color_continuous_scale='Viridis'
             template='plotly_dark'
            )

# Figure layout
fig.update_layout(
    bargap=0.2,
    xaxis=dict(tickmode='linear'),
    yaxis=dict(title='Compound'),
    showlegend=True,
)

fig.show()

Removing the dark theme doesnโ€™t make the colors stand out either, theyโ€™re too light.

Any idea how to fix the colors and make them stand out?

I think this is because you are using a bar chart in the second example. All single values are stacked. Take a look here:

Search on this page for See also: Bar Charts

EDIT: Welcome to the forums!

2 Likes

Thank you so much for your help. I think that by just changing it to a histogram function, I may have resolved my issue!

1 Like