When summing two charts with identically ordered axis, the order is lost.
See original GitHub issueHi, I’m rather new to the library and this is probably derived from my lack of full understanding of it, but since this behavior is a little bit surprising I wanted to ask if it is expected.
I have two dataframes:
import altair as alt
import pandas as pd
laureates = pd.DataFrame({
'name': ['B', 'D', 'C', 'A'],
'born': pd.to_datetime(['1900-01-01', '1905-01-01', '1930-01-01', '1960-01-01']),
'died': pd.to_datetime(['1950-01-01', '1965-01-01', '1970-01-01', '2015-01-01'])
})
prizes = pd.DataFrame({
'name': ['B', 'B', 'D', 'C', 'A'],
'date': pd.to_datetime(['1930-01-01', '1935-05-01', '1936-01-01', '1965-01-01', '2000-01-01'])
})
And I did the following two charts:
dots = alt.Chart(prizes.merge(laureates, on='name'))\
.mark_point(fill='black')\
.encode(y='date:T', x=alt.X("name:N", sort=["born:T"]))
lines = alt.Chart(laureates)\
.mark_rule()\
.encode(y="born:T", y2="died:T", x=alt.X("name:N", sort=["born:T"]))
Independently, both graphs render more or less as I intended:
But when I sum them with lines + dots
the ordering in the x-axis reverts to alphabetical:
Is this expected? If so, how do I keep the original ordering? Or how do I reorder the axis after joining the charts?
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Change the plotting order of categories, values, or data series
On a chart, do one of the following: To change the plotting order of categories, click the horizontal (category) axis. · On the...
Read more >Multiple Time Series in an Excel Chart - Peltier Tech
This discussion mostly concerns Excel Line Charts with Date Axis formatting. Date Axis formatting is available for the X axis (the independent ...
Read more >An Introduction to Combinatorics and Graph Theory
A permutation of some objects is a particular linear ordering of the objects; P(n, k) in effect counts two things simultaneously: the number...
Read more >Create a Pareto Chart - Tableau Help
A Pareto chart is a type of chart that contains both bars and a line graph, where individual values are represented in descending...
Read more >ggplot with 2 y axes on each side and different scales
The original ggplot objet is then manipulated with Kohske's helper function PlotWithFudgeAxis to add a second axis preserving the scales of y2. It...
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
This is a bug in Vega-Lite; see #820 and vega/vega-lite#3710. Closing as a duplicate.
As @jakevdp suggests in #820, you can update one of your
alt.X
specifications to turn off the second axis: