Setting tick labels to list of strings
See original GitHub issueHi everyone,
Is there a way to set the tick labels in a chart to some list of strings? Here is the chart:
df=pd.DataFrame({'days_between': [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6],
'person': [1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2,2],
'value': [10,11,12,13,14,15,10,11,12,13,14,15]})
alt.Chart(df).mark_square(size=400).encode(
x=alt.X('days_between:Q', axis=alt.Axis(values=[1,2,3,4,5,6])),
y=alt.Y('person:Q', axis=alt.Axis(values=[1,2])),
color=alt.Color('value:Q', scale=alt.Scale(range=['green','yellow','red']))).properties(width=400, height=400).interactive()
I would have thought this would work (similar to matplotlib in some sense):
alt.Axis(..., labels=['string 1', 'string 2', 'string 3', 'string 4', 'string 5', 'sting 6'])
Is there a way to do this when using quantitative data types as I am in the above example?
Issue Analytics
- State:
- Created 5 years ago
- Reactions:5
- Comments:17 (12 by maintainers)
Top Results From Across the Web
Change x-axis ticks to custom strings [duplicate] - Stack Overflow
I want to change the x-axis ticklabels to custom strings, but the following does not work. How can I set the ticklabels to...
Read more >Setting tick labels from a list of values - Matplotlib
Using Axes.set_xticks causes the tick labels to be set on the currently chosen ticks. However, you may want to allow matplotlib to dynamically...
Read more >Set or query x-axis tick labels - MATLAB xticklabels - MathWorks
This MATLAB function sets the x-axis tick labels for the current axes. ... Specify labels as a string array or a cell array...
Read more >Matplotlib - Setting Ticks and Tick Labels - GeeksforGeeks
In this article, we are going to discuss how set Ticks and Tick labels in a graph. Ticks are the markers denoting data...
Read more >Customizing Ticks | Python Data Science Handbook
We see here that each major tick shows a large tickmark and a label, while each minor tick shows a ... IndexFormatter, Set...
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
Am I able to do this with date values ala:
Altair is designed to properly display whatever data you input regardless of the type, unlike matplotlib which requires you to input quantitative data and then manually re-map the axes to whatever non-quantitative data you want it to represent.
So I’d say the best approach to this for Altair is to actually use the values of interest within the dataset itself, and then no manual axis label mapping will be necessary.
For example: