Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the colorbar range in plotly express graph?

Tags:

plotly

How can I change the color range in ploty express scatter plots?

import plotly.express as px

...

fig = px.scatter(data, 
                 x="X-coord", 
                 y="Y-coord", 
                 animation_frame="Timepoint",
                 color="Fraction", 
                 hover_name="Compound",
                 size_max=10,
                 size='Fraction')

enter image description here

I want the colorbars to show a range from 0 to 1.

like image 821
Soren Avatar asked Aug 06 '19 20:08

Soren


People also ask

What is continuous color in Plotly Express?

Most Plotly Express functions accept a color argument which automatically assigns data values to continuous color if the data is numeric. If the data contains strings, the color will automatically be considered discrete (also known as categorical or qualitative).

What is the default color scale in Plotly Express?

By default, Plotly Express will use the color scale from the active template 's layout.colorscales.sequential attribute, and the default active template is plotly which uses the Plasma color scale. You can choose any of the built-in color scales, however, or define your own.

Can Plotly represent categorical data with color?

This page is about using color to represent continuous data, but Plotly can also represent categorical values with color. This document explains the following four continuous-color-related concepts:

How to configure color bars in go?

Color bars can be configured with attributes inside layout.coloraxis.colorbar or in places like marker.colorbar in go.Scatter traces or colorbar in go.Heatmap traces. color axes connect color scales, color ranges and color bars to a trace's data.


1 Answers

You can add range_color=(0,1) to the keywords of px.scatter.

like image 51
Soren Avatar answered Oct 07 '22 13:10

Soren