-
Notifications
You must be signed in to change notification settings - Fork 795
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to set the color of a plotted line directly/manually? #1466
Comments
Two ways to do this: alt.Chart(df).mark_line(color="#FFAA00").encode(
x='x',
y='y'
) or alt.Chart(df).mark_line().encode(
x='x',
y='y',
color=alt.value("#FFAA00")
) The reason your first approach doesn't work is because it indicates you want to encode using a column named See Customizing Visualizations for more information. |
Thanks, not sure how I missed that. |
Hi, I am using multi chart and there is no way to specify the legends directly. So as a hack, introduced a separate legend column to each of the charts. However, still stuck with giving colour of my own choice. Colour has to be consistent for different plots that will be drawn several times for different timeframes on the same page. Here is an example:
The above plot gives different color each time and would like to know if there is a way to mention alt.value after color column. Thanks in advance. |
You can specify a desired color scale using |
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) |
I 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:
#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:
but this does not work.
Thanks.
The text was updated successfully, but these errors were encountered: