How to put characters in the vise of the X-axis in Julia Gadfly?

I would like to plot a curve (e.g. sine) with the X axis at -pi / 2, 0, pi / 2, but I would like:

  • have ticks only at these points;
  • have the symbol pi (ie Ο€, Ο€ / 2, etc.) in the tick, and not the text "pi", "pi / 2", etc.

How is this possible with Julia Gadfly?

+4
source share
2 answers

To have ticks at any points. ex, at Ο€/2and Ο€try this,

julia>plot([sin,cos],0,6, Stat.xticks(ticks=[Ο€/2,Ο€]))

enter image description here

It is impossible to have characters like Ο€ as ticks.

+1
source

Julia supports utf encodings, so to display the pi character you do this

pi = char(960)

960 pi. Gadfly, 960 ( , ). , @sprintf.

:

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")

enter image description here

0

Source: https://habr.com/ru/post/1532476/


All Articles