Open hutou opened 1 month ago
Please refer to Example code on using custom gnuplot commands
Sorry, but the example doesn't do what I want. I don't want to display integers (hours, days or years) in x, but dates, specifying the format (e.g. mm/yy). Is this possible? Thanks
I don't want to display integers (hours, days or years) in x, but dates, specifying the format (e.g. mm/yy). Is this possible?
Yes. As long as functionality is supported by Gnuplot you can do that. For your required use-case, something like below would do the trick
ydata = [10, 15, 7, 20, 5]
dates = ["2024-10-01", "2024-10-05", "2024-10-10", "2024-10-15", "2024-10-20"]
plot = Cryplot.plot {
size(480, 380)
palette(:dark2)
legend.hide
xlabel("Date")
ylabel("Value")
title("Sample Plot with Dates on X-axis")
gnuplot("set xdata time")
gnuplot("set timefmt '%Y-%m-%d")
xtics.rotate(-45)
draw_boxes(dates, ydata)
show
}
when executed above code, you will see something like (PS: I've rotated the x-axis labels to avoid cluttering. you can change that to any angle you like)
Ah, I hadn't seen the gnuplot function! Thanks
Gnuplot documentation says:
How can I use these commands in Cryplot ? Thanks