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.

How to type Math Symbol into labels or title?

See original GitHub issue
import altair as alt
import pandas as pd
import numpy as np

# Create a selection that chooses the nearest point & selects based on x-value
nearest = alt.selection(type='single', nearest=True, on='mouseover',
                        fields=['Time'], empty='none')

# The basic line
line = alt.Chart().mark_line(interpolate='basis',color='#333').encode(
    x=alt.X('Time:T',axis=alt.Axis(title='Date')),
    y=alt.Y('PM25:Q',axis=alt.Axis(title='PM2.5 (μg/m3)'))
)

I tried putting the unit to my y-axis label. Coming from matplotlib I first tried y=alt.Y('PM25:Q',axis=alt.Axis(title=r'PM2.5 $(\mu g/m^{3})$')). For now I used Jupyter notebook to type μ but still didn’t figure out how to type the power. I searched through the documentation but didn’t find a solution.

Please help me out if there is a way to do it. Thank you!

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
mattijncommented, Aug 21, 2018

Only Unicode characters are supported in Vega. Meaning that rendering of LaTeX text and MathJax is not supported in Altair

You can search for the corresponding superscript character at this page: https://en.wikipedia.org/wiki/Unicode_subscripts_and_superscripts and copy the character of interest in your specification.

Maybe Altair could implement a preprocessing feature that convert defined MathJax to Unicode characters.

2reactions
jakevdpcommented, Apr 16, 2020

The relevant Vega feature request is here: https://github.com/vega/vega/issues/898

Read more comments on GitHub >

github_iconTop Results From Across the Web

Insert mathematical symbols - Microsoft Support
Symbol set Subset Definition Greek Letters Lowercase Lowercase letters from the Greek alphabet Uppercase Uppercase letters from the Greek alphabet Letter‑Like Symbols None Symbols that resemble...
Read more >
r - Putting mathematical symbols and subscripts mixed with ...
I think the 'labels' argument to annotate takes a character mode You could look up what Unicode value 'sigma' might have in the...
Read more >
Mathematical Annotation in R
In this article we demonstrate how to include mathematical symbols ... a formula in the title of the plot, adding symbols to axis...
Read more >
Math Notation for R Plot Titles: expression, bquote, & Greek ...
Use bquote · Strings – Require quotes wrapped w/ tilde separator (e.g., "my text" ~ ). · Math Expressions – Unquoted & follow...
Read more >
Using Special Formats and Symbols in Titles
To display a backslash (\) in, for example, a title, use \backslash. HTML Tags. You can use the following HTML tags in text...
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