JuliaTeX / PGFPlots.jl

This library uses the LaTeX package pgfplots to produce plots.
Other
188 stars 36 forks source link

Significant Figures #155

Closed Bebotron closed 3 years ago

Bebotron commented 4 years ago

I couldn't find this anywhere in the examples notebook. I'm trying to manipulate the number of significant figures on my axis ticks.

I have the following data

julia> data
10×2 Array{Float64,2}:
  10.0  0.986932
  20.0  0.991782
  30.0  0.993552
  40.0  0.994498
  50.0  0.995099
  60.0  0.995522
  70.0  0.995839
  80.0  0.996087
  90.0  0.996287
 100.0  0.996454

And I'm running Plots.Scatter(data[:,1], data[:,2]), this produces the following plot

test

This y-axis is completely pointless, and I can't find how to fix it (show 3 significant figures)

mossr commented 3 years ago

This can be done through the style keyword of Axis and using standard pgfplots settings:

Axis(Plots.Scatter(data[:,1], data[:,2]), style="yticklabel style={/pgf/number format/precision=3}")

image

As a future reference, there are a lot of customizable things you can do purely in pgfplots that may not have a direct keyword in PGFPlots.jl, and we use the style option as a somewhat catch-all.

Here's more information about pgfplot precision: https://tex.stackexchange.com/questions/220969/pgfplots-significant-figures