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.

Change language of timeline-stripplot

See original GitHub issue

Hey dear all,

I really love what you guys provide with Altair and it is a lot of fun to play around with it. I was wondering, if there is a way to change ticks on a timeline-stripplot into another languages datetime-format (in my case German). I have tried just changing the locale but that had no effect on the graph. Is there a way to custom-map axis ticks from the data-values in the dataset to something converted without the order of the ticks being scrambled up?

Again thank you so much for all your work

alt.Chart(terrordata,
    description='Shows the frequency of terror attacks between two countries.',
).mark_tick(tickThickness=1.5, font="arial").encode(   
x=alt.X('date:T',axis=alt.Axis(format='%B %Y',title='', labelAngle=0, axisWidth=0,ticks=4, orient="top",)),
    y=alt.Y('country:N',axis=alt.Axis(title='', axisWidth=0), font="Helvetica Neue", fontsize=20),
    color=alt.Color("casualties:Q",
            legend=alt.Legend(
                title='Todeszahlen',
                titleFont="s-font-serif",
                titleFontWeight="12",
            ),
            scale=alt.Scale(
                domain=['0', '5'],
                range=['#ffb6b6', '#e23b3c'],
            ),
        ),).configure_cell( width=800).configure_scale(bandSize=100).configure_axis(
    titleFont="s-font-serif",
    titleFontSize=16,
    tickLabelFont="s-font-serif",
    tickLabelFontSize=12,
    tickSize=0
)

stripplot

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:32 (19 by maintainers)

github_iconTop GitHub Comments

2reactions
jakevdpcommented, Apr 3, 2020

For time format locale, you can pass a dict object from https://github.com/d3/d3-time-format/tree/master/locale to the embed options. For example:

from urllib import request
import json

# fetch & enable a German time locale.
with request.urlopen('https://raw.githubusercontent.com/d3/d3-time-format/master/locale/de-DE.json') as f:
  de_time_format = json.load(f)
alt.renderers.set_embed_options(timeFormatLocale=de_time_format)

# plot the chart
df = pd.DataFrame({
    'date': pd.date_range('2020-01-01', freq='D', periods=180),
    'value': np.random.randn(180).cumsum()
})

alt.Chart(df).mark_line().encode(
    x='date',
    y='value',
)

visualization - 2020-04-03T135909 993

It might be worth adding some convenience functions to Altair and put some examples in the documentation.

1reaction
domoritzcommented, Nov 17, 2019

Vega-Embed 6.1.0 supports formatLocale and timeFormatLocale. I think this issue can be closed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Hardwired..for tidy text - R-bloggers
Hello, R users! This week we're continuing to bridge the gap between computers and human language with the launch Sentiment Analysis in R:...
Read more >
How To Set Time Axes Labels (Ticks) Based On German Locale
An algorithm using R language has been developed for constructing Computer ... I was wondering if there is a way to change ticks...
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