-
-
Notifications
You must be signed in to change notification settings - Fork 348
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Plotting with Serif Font, scientific notation #2042
Comments
Hi @isentropic, I just want to start off by explaining there was a slight bug with the code snippet you used above. You should replace the
(see comments by nathancunn in #897 for explanations) Also, I assume you generated the above plots with code similar to the following:
If not, please provide such code for clarity. |
As for the trouble rendering powers of 10: BackgroundIt would appear that most backends display the exponential portion of the powers of 10 by using the unicode characters for +, -, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9. These are special characters that are already positionned in the superscript position... so that plotting backends just have to build a unicode string & render it using the drawing backend (ex: Cairo). You can read more about it here: (Note that the tables preceed the exponent with an "X" just so you can see that the numbers are indeed superscripts (or subscripts). Alternative ImplementationPlotting backends could scale down the font size, and render the exponent part at a vertically offset location - but most just don't do that (InspectDR does it for the tick labels on log plots, though). ProblemThe problem is that the font you selected does not actually provide "drawings" for the "exponent" unicode characters. SolutionThe easiest solution right now is to select a font that "renders/implements" the exponent numbers. A quick way to check this would be to copy/paste the unicode "exponents" into a text editor (like LibreOffice), and see whether something shows up when select a desired font. You should be able to copy/paste the following unicode characters:
Of course you will only see the above exponents if your browser font currently "implements" their drawings. |
At least on GR and PyPlot, instead of plot(cumsum(1:10), xlabel = "x label", ylabel = "x label", title = "title", dpi = 50) plot(cumsum(1:10), xlabel = "x label", ylabel = "x label", title = "title", dpi = 300)
|
The problem is that the same config works perfectly fine if done in python via pyplot, or PyPlot package in Julia. PyPlot and python's pyplot in the absence of said fonts would then: I think you merely reformulated the problem in more technical terms, it is not a solution. The package should workaround if ligatures are not available like pyplot does natively. |
@daschw: That's good to know about DPI. The behaviour seems to make sense compared to what we had in 2017. But I don't think this solves the problem: It seems like the issue is that exponent parts (after the 10) don't show up when @isentropic selects the "Latin Modern Math" font. And that's simply because this font does not actually include "drawings" for the exponent "characters". |
@isentropic: Here, Pyplot is using "E" notation (instead of the more natural x10⁸) on the y-axis of the plot above, and decided to display many decimal places (again instead of the easier to read x10⁻³ notation) on the x-axis. If you change the range on the x-axis to smaller values (ex: x10⁻¹²), you will likely "force" Pyplot to use scientific notation, and get similar results. Again, as far as I can see the problem is that the "Latin Modern Math" font is lacking the ability to "draw" exponential "characters" I'm not saying this just to be technicial: I'm simply hilighting the root of the problem. I don't think it would be reasonable for a plotting backend to somehow detect that the selected font "did not implement" the exponent portions, and find a way to work around this issue. At best, the user should be aware that her font was missing the exponent portion, and maybe then select a different rendering method for the tick labels. NOTE:
That way, you could circumvent the font limitations, if you so choose. |
I just expected to see Plots.jl's pyplot backend provide the same workaroundish "1e-9" like values which are good enough for reproducing the original Pyplot behavior. I just do not understand why Plots.jl does not behave the same way. I assumed it to work the same |
I've been looking at alternatives, but still could not solve my issue. Does anyone know any Sans-Serif fonts that would have the said ligatures 10^(-1; -2; -3 ...) (scientific notation)?
was that I believe that this font supports exponents and various math. symbols |
I suppose it depends both on the operating system (Linux, Windows, ...) and the drawing package. For plotting packages that use Cairo, you can actually select: The font "sans" is supposed to be the default sans-serif font. VERY IMPORTANT NOTE ON CAIRO
Alternative on WindowsOn my windows 10 machine, I have to resort to selecting "Calibri" (which appears to be bundled with Windows 10). I don't know why Cairo cannot pick a "fully populated" sans-serif font in WIndows 10 when you request the "sans" fontname. |
I have tested this issue for plotlyjs gr and pyplot backends in a jupyter notebook again (I'm running Ubuntu)
I tested it with different fonts, results are the same: Exponents do not render properly. (Even tried powerline monospace fonts that have all the ligatures and more) I think that is something with the way Plots.jl handles the scientific notation, native Pyplot or Plotly do not do this. Let me know if you'd need more tests to figure out why this happens, I'd gladly attempt to fix this, but I do not know how. I have checked all the Attributes to see if there is "Exponent font" or smth like that, I could not find any other font attributes that I could have changed. The issue remains with |
I'm actually not convinced we are talking about the same thing, but here is what I myself get using the When
|
Following 897, I attempted to make the plot look different,
The problem is that backends have trouble rendering powers of 10:
![image](https://user-images.githubusercontent.com/24591123/58609794-e0aafc80-82e3-11e9-820a-0f7904f9e10a.png)
PyPlot handles this as follows (example):
![image](https://user-images.githubusercontent.com/24591123/58609813-020be880-82e4-11e9-8623-ad0f9d5f8c7e.png)
Are there any additional parameters that require tuning?
The text was updated successfully, but these errors were encountered: