How to set the color of a plotted line directly/manually?
See original GitHub issueI have found some examples where a color scale is defined and a category variable is chosen based on which the plots are colored. E.g. here: https://github.com/altair-viz/altair/issues/921
I want the user to be able to plot various lines onto a LayerChart, and select the color manually for each line added (i.e. choose a color from a dropdown list, click plot, and add a new plot to the existing chart with the color chosen). How can I directly tell altair to plot using a certain color?
I tried:
lines = alt.Chart(df).mark_line().encode(
x=alt.X(...),
y=alt.Y(...),
color='rgb(255,184,56)'
)
but this does not work. Thanks.
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Control How Plotting Functions Select Colors and Line Styles
You can change the colors, line styles, and markers of plot objects by modifying the ColorOrder or LineStyleOrder properties of the axes, or...
Read more >How to change the plot line color from blue to black?
The usual way to set the line color in matplotlib is to specify it in the plot command. This can either be done...
Read more >matplotlib.pyplot.plot — Matplotlib 2.1.2 documentation
Line styles and colors are combined in a single format string, as in 'bo' for blue circles. The kwargs can be used to...
Read more >How to change Colors in ggplot2 Line Plot in R - GeeksforGeeks
It utilizes points and lines to represent change over time. Line graphs are drawn by plotting different points on their X coordinates and...
Read more >How to Change Plot Line Styles and Colors in MATLAB
... details about customization of Plots in terms of Styles and Colors in MATLAB.Contents of the Video:1. Plots in MATLAB2. Change Line S......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Two ways to do this:
or
The reason your first approach doesn’t work is because it indicates you want to encode using a column named
'rgb(255,184,56)'
.See Customizing Visualizations for more information.
Thanks. It fit my purpose. Though I tried alt.Scale as suggested here, the color is not consistent for the plots called several times on the same page. Now it is. Probably I missed a common range/domain definition.
Here is my not so good looking code. Just in case it helps someone introduce legends to multi layer, though I don’t recommend taking this path…
(Of course, I would like to avoid ‘eval’ … work in progress)