Including gradients or segments to the background of a plot may help enhance the readability of the knowledge that you’re making an attempt to current. It may assist draw consideration to areas which are excessive or low, or it may be used to establish if a measurement goes out of tolerance. For instance if an LWD logging instrument is experiencing excessive vibrations which exceed the specification for that instrument or it may be used for temperature information to spotlight cold and hot areas.
On this article, I’ll share how we are able to, with a bit of little bit of code, add a gradient background to a Plotly Categorical line chart.
Earlier than we are able to start making plots we first must create a dataset. For this instance, I’m utilizing randomly generated temperatures over time period.
First, we might want to import the libraries we’re going to use.
- plotly categorical can be used to generate our plot
- matplotlib can be used to generate our color map and convert the chosen values to hexidecimal
- numpy can be used to assist create our color scale
import plotly.categorical as px
import matplotlib.pyplot as plt…