Discrete Colour Scale in Plotly Python Last Updated : 28 Apr, 2025 Comments Improve Suggest changes Like Article Like Report In the Cartesian plane for X and Y coordinates, colors can be used to represent data on the graph to make it more understandable. This color label can be used to display continuous or discrete data both. Python Plotly can be used to display both the color representation i.e. continuous(moments in time) and discrete(categorical). In this article, we will display both color representations for discrete and continuous(color scale) using Python. Here firstly we will see the continuous color representation then on the same dataset, we will see discrete color representation. Required Module: The plotly.express module can create the entire Figure at once. It uses the graph_objects internally and returns the graph_objects.Figure instance. pip install plotly-expressContinuous/Color-scale representation Here we will first import the Plotly python library. As we are going see that in a certain restaurant on which day how much total bill is issued to the customers and how much total tips are given by the customers to the waiters. So 'day' is plotted to Y-axis and 'total_bill' is plotted to X-axis. The dataset is in-build with Plotly. No other dataset is need to be downloaded or put in input. Python3 import plotly.express as pltx dataFrame = pltx.data.tips() figure = pltx.scatter(dataFrame, x="total_bill", y="day",color="tip", title="String 'tip' values\ (Total Bill vs Day) in mean continuous \ colors representation") figure.show() Output: continuous or color scale representationDiscrete Color representation Now we will plot the same graph with the discrete color technique. For discrete colors, we need to calculate the exact values of the 'tip' instead of the value range. For doing this simply we will convert the value range of 'tip' to the string and then we will plot it. From the output, we can see that instead of a color scale that shows up the value range, discrete color representation is showing results with exact values. So, only with a single line of code, we can easily convert the representation from color-scale to discrete representation. Python3 import plotly.express as pltx dataFrame = pltx.data.tips() # converting the values to string dataFrame["tip"] = dataFrame["tip"].astype(str) figure = pltx.scatter(dataFrame, x="total_bill", y="day",color="tip", title="String 'tip' values(Total \ Bill vs Day) in mean discrete colors \ representation") figure.show() Output: discrete color representation Comment More infoAdvertise with us Next Article Discrete Colour Scale in Plotly Python susmit_sekhar_bhakta Follow Improve Article Tags : Technical Scripter Python Technical Scripter 2022 Practice Tags : python Similar Reads Built-in Continuous Color Scales in Python Plotly Plotly has built-in discrete and continuous color scales. This article is about discrete color scales. A color continuous scale input is accepted by several Plotly Express functions, and many trace types have a color scale property in their schema. Plotly has a wide variety of built-in continuous co 3 min read Bar chart using Plotly in Python Plotly is a Python library which is used to design graphs, especially interactive graphs. It can plot various graphs and charts like histogram, barplot, boxplot, spreadplot, and many more. It is mainly used in data analysis as well as financial analysis. Plotly is an interactive visualization librar 4 min read How to create Stacked bar chart in Python-Plotly? Plotly is a Python library which is used to design graphs, especially interactive graphs. It can plot various graphs and charts like histogram, barplot, boxplot, spreadplot and many more. It is mainly used in data analysis as well as financial analysis. plotly is an interactive visualization library 2 min read Matplotlib.axes.Axes.get_xscale() in Python Matplotlib is a library in Python and it is numerical - mathematical extension for NumPy library. The Axes Class contains most of the figure elements: Axis, Tick, Line2D, Text, Polygon, etc., and sets the coordinate system. And the instances of Axes supports callbacks through a callbacks attribute. 2 min read Matplotlib.axes.Axes.get_yscale() in Python Matplotlib is a library in Python and it is numerical - mathematical extension for NumPy library. The Axes Class contains most of the figure elements: Axis, Tick, Line2D, Text, Polygon, etc., and sets the coordinate system. And the instances of Axes supports callbacks through a callbacks attribute. 1 min read Matplotlib.pyplot.xscale() function in Python Matplotlib is a library in Python and it is numerical â mathematical extension for NumPy library. Pyplot is a state-based interface to a Matplotlib module which provides a MATLAB-like interface. There are various plots which can be used in Pyplot are Line Plot, Contour, Histogram, Scatter, 3D Plot, 2 min read Sankey Diagram using Plotly in Python Plotly is a Python library that is used to design graphs, especially interactive graphs. It can plot various graphs and charts like histogram, barplot, boxplot, spreadplot, and many more. It is mainly used in data analysis as well as financial analysis. plotly is an interactive visualization library 2 min read Filled area chart using plotly in Python Plotly is a Python library that is used to design graphs, especially interactive graphs. It can plot various graphs and charts like histograms, bar plots, box plots, spread plots, and many more. It is mainly used in data analysis as well as financial analysis. Plotly is an interactive visualization 6 min read How to create Tables using Plotly in Python? Plotly is a Python library that is used to design graphs, especially interactive graphs. It can plot various graphs and charts like histogram, barplot, boxplot, spreadplot, and many more. It is mainly used in data analysis as well as financial analysis. plotly is an interactive visualization library 2 min read Parallel Coordinates Plot using Plotly in Python A Plotly is a Python library that is used to design graphs, especially interactive graphs. It can plot various graphs and charts like histogram, barplot, boxplot, spreadplot, and many more. It is mainly used in data analysis as well as financial analysis. Plotly is an interactive visualization libra 2 min read Like