vary the color of a line with points overlayed
See original GitHub issueHi Altair users,
Loving Altair but I have a question. How would I have a line mark that varies in color and has the circle marks overlayed? The following does not show the line:
import altair as alt
import numpy as np
import pandas as pd
x = np.arange(100)
data = pd.DataFrame({'x': x,
'sin(x)': np.sin(x / 5)})
c=alt.Chart(data).encode(
x='x',
y='sin(x)',
color='sin(x)'
)
c.mark_circle() + c.mark_line()
Am I doing something wrong here? I have also tried the trail marker. This shows the same as the attached image.
In fact the chart is empty if I only use the line mark here.
import altair as alt
import numpy as np
import pandas as pd
x = np.arange(100)
data = pd.DataFrame({'x': x,
'sin(x)': np.sin(x / 5)})
c=alt.Chart(data).encode(
x='x',
y='sin(x)',
color='sin(x)',
)
c.mark_line()
Thanks for the great package.
Al
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Vary the colors of same-series data markers in a chart
To use different colors for each data marker, you can vary the colors automatically by using the Vary colors by point or Vary...
Read more >How to assign colors to multicolor scatter plot ... - Stack Overflow
Use the colour aesthetics for both points and lines (specify in ggplot such that it gets inherited throughout). By default, geom_point can map...
Read more >Different Colors of Points and Lines in Base R Plot Legend
In this article, we are going to see how to plot different colors of points and lines in base R Programing Language.
Read more >Is there a way to set the plot color for a particular analysis and ...
When you create the overlay plot, it will display the colors you have selected for each data ... Other settings, such as the...
Read more >Be Awesome in ggplot2: A Practical Guide to be Highly Effective
Geometry corresponds to the type of graphics (histogram, box plot, line ... The following R code will change the color and the shape...
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
You could probably hack it by manually constructing line segments containing two points each, duplicating the data between start and end point. But that’s not particularly convenient.
I agree that making the trail mark support color would be the natural way to support this within the vega-lite grammar. It might be worth a feature request to vega-lite!
Thanks Jake. I will hack in that way if needed. I mentioned it to the Vega people.
Take care, Al