question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

vary the color of a line with points overlayed

See original GitHub issue

Hi 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()

visualization 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()

visualization 1

Thanks for the great package.

Al

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
jakevdpcommented, Jun 11, 2018

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!

2reactions
Alcampopianocommented, Jun 11, 2018

Thanks Jake. I will hack in that way if needed. I mentioned it to the Vega people.

Take care, Al

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found