Reputation: 532
I would like to plot a (e.g. sine) curve with X-axis on -pi/2, 0, pi/2, but I wanted:
How is it possible with Julia's Gadfly?
Upvotes: 4
Views: 1140
Reputation: 1208
To have ticks at any points. e.x, at π/2
and π
try this,
julia>plot([sin,cos],0,6, Stat.xticks(ticks=[π/2,π]))
It is not possible to have symbols like π as ticks.
Upvotes: 1
Reputation: 464
Julia supports utf encodings, so to render the pi symbol you'd do this
pi = char(960)
With 960 being the integer code for pi. When I used this directly in the Gadfly plot legend, it was rendered as a color bar on max range 960 (no idea why). But I got around that by using @sprintf macro.
Final solution:
using Gadfly
using DataFrames
Gadfly.set_default_plot_size(20cm, 12cm)
pi = @sprintf("%s", char(960))
df1 = DataFrame(x=rand(100), y=rand(100), label=s)
plot(df1, x="x", y="y", color="label")
Upvotes: 0