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.

Artifact with mark_area() when coloring intervals

See original GitHub issue

I am attempting to shade an area under a curve between two points to demonstrate an integral, but I get a strange plotting artifact:

import numpy as np
import altair as alt
import pandas as pd

x = np.arange(-1,1,0.01)
y = np.exp(x)
A = (-0.8<=x) & (x<0.8)

data = pd.DataFrame({'x':x, 'y':y, 'A':A})
alt.Chart(data).mark_area().encode(x='x', y='y', color='A:N')

visualization (14)

The behavior is different if I set different limits for the shaded area:

A = (-1<=x) & (x<0)

data = pd.DataFrame({'x':x, 'y':y, 'A':A})
alt.Chart(data).mark_area().encode(x='x', y='y', color='A:N')

visualization (15)

Perhaps I am misusing mark_area(), but I can’t find anything in the documentation or other issues discussing how to do this correctly, and the fact that the behavior is different in these two cases makes me think it’s a bug, not misuse.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
jakevdpcommented, Nov 7, 2019

The best way to avoid a space between the sections would probably be to use a layer with the filtered dataset:

import numpy as np
import altair as alt
import pandas as pd

x = np.arange(-1,1,0.01)
y = np.exp(x)
A = (-0.8<=x) & (x<0.8)

data = pd.DataFrame({'x':x, 'y':y, 'A':A})
base = alt.Chart(data).mark_area().encode(x='x', y='y')
base + base.transform_filter('datum.A').mark_area(color='darkorange')

visualization (30)

0reactions
jakevdpcommented, Nov 7, 2019

Oh, your working example has space between the sections, so I thought that was what you were expecting.

Read more comments on GitHub >

github_iconTop Results From Across the Web

CSC 373 Lecture # 2 Instructor: Milad Eftekhar Interval ...
Interval Coloring (a.k.a. Interval Partitioning): ... Goal: Color all the intervals with as few colors as possible so that intervals having the same...
Read more >
Graph coloring with intervals Gurobi constraints - Stack Overflow
Using this code, the model is unfeasible. I know that variable x and constraints 2a are defined in the right way. I'm not...
Read more >
[1802.09503] Online Coloring of Short Intervals - arXiv
Abstract: We study the online graph coloring problem restricted to the intersection graphs of intervals with lengths in [1,\sigma].
Read more >
Interval Graph Coloring Problem - Gustavus Adolphus College
Interval Graph Coloring Problem. GT: Ch 10.2. Problem. Given n lectures, each with a start time and a finish time, find a minimum...
Read more >
Interval edge coloring - Wikipedia
In graph theory, interval edge coloring is a type of edge coloring in which edges are labeled by the integers in some interval,...
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