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.

[Question] Draw scatterplot of wedges with encoded size and angle

See original GitHub issue

I want to implement Zan Armstrong’s comet chart in Altair, for which I need to draw a scatterplot of wedges with encoded start-point and end-points. I used glyphs in an earlier implementation in Bokeh.

I have read about wedge as one of the available marks, and managed to draw wedges, all with the same configuration e.g. just changing the angle.

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

df = pd.DataFrame(
    np.hstack((np.random.randn(100, 2), np.random.randint(0, 360, (100, 1)))),
    columns=["x", "y", "angle"],
)

(alt.Chart(df).mark_point(shape='wedge', angle=135).encode(x="x:Q", y="y:Q"))

I was wondering whether it is possible to encode the wedges individually, where the length and direction are determined by the start and endpoint in the dataset. As a first test, I tried to encode angle='angle:Q in the example above, but that property isn’t defined.

Vega-lite shape mark looks like another possible solution (see this SO post) and I see it is accessible in Altair as shown here) but I don’t know how to connect the dots.

If someone could point me in the right direction, I am happy to try and contribute a comet chart viz to Altair.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:18 (11 by maintainers)

github_iconTop GitHub Comments

2reactions
dkapitancommented, Jan 29, 2021

@mattijn Thanks for the suggestions. I have just finished up writing a short blog post.

Happy to contribute. Your plot with the barley yield data, however, is not quite what is meant with a comet chart (although it does borrow elements from it). So just to check, I can submit a PR with the barley yield example, and we’ll just leave the rest of my work in the blogpost if that’s what you mean.

1reaction
morbergcommented, Feb 9, 2021

It is up to @jakevdp to decide what goes in and where. This thread might be difficult to follow since it started as a question.

I would close this issue and create a new separate issue offering to create a PR to include your example. Jake will most likely chime in with what is needed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

A Complete Guide to Scatter Plots - Chartio
Scatter plots are an essential type of data visualization that shows relationships between variables. Use this tutorial to learn how to use this...
Read more >
matplotlib.pyplot.scatter() in Python - GeeksforGeeks
It is used for plotting various plots in Python like scatter plot, bar charts, pie charts, line plots, histograms, 3-D plots and many...
Read more >
Chapter 4. Visualization with Matplotlib - O'Reilly
We can see that this scatter plot has given us the ability to simultaneously explore four different dimensions of the data: the (x,...
Read more >
Change the Type of Mark in the View - Tableau Help
It is also color-encoded by a dimension (Category). Because the Marks card drop-down menu is set to Automatic, data is displayed using bars....
Read more >
Describing scatterplots (form, direction, strength, outliers)
It also mentions the context of the two variables in question (age of drivers and number of accidents). Practice. Problem 1. Choose the...
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