Stream: helpdesk (published)

Topic: ✔ won't plot x values for histogram


view this post on Zulip Yuu Yin (Mar 26 2023 at 19:11):

@Daniel González

Following your suggestions, I

using Plots

# Define data
x::AbstractVector = [
    02.97; 04.00; 05.20; 05.56; 05.94; 05.98; 06.35; 06.62; 06.72; 06.78;
    06.80; 06.85; 06.94; 07.15; 07.16; 07.23; 07.29; 07.62; 07.62; 07.69;
    07.73; 07.87; 07.93; 08.00; 08.26; 08.29; 08.37; 08.47; 08.54; 08.58;
    08.61; 08.67; 08.69; 08.81; 09.07; 09.27; 09.37; 09.43; 09.52; 09.58;
    09.60; 09.76; 09.82; 09.83; 09.83; 09.84; 09.96; 10.04; 10.21; 10.28;
    10.28; 10.30; 10.35; 10.36; 10.40; 10.49; 10.50; 10.64; 10.95; 11.09;
    11.12; 11.21; 11.29; 11.43; 11.62; 11.70; 11.70; 12.16; 12.19; 12.28;
    12.31; 12.62; 12.69; 12.71; 12.91; 12.92; 13.11; 13.38; 13.42; 13.43;
    13.47; 13.60; 13.96; 14.24; 14.35; 15.12; 15.24; 16.06; 16.90; 18.26;
]
classIntervals = range(start=1, step=2, stop=19)

# Set and export plot
plotHistogram = histogram(x, bins=classIntervals, label="Experimental", color=:cool)
xlims!(0, 19)
ylims!(0, 30)
title!("energy consuption")
xlabel!("x")
ylabel!("Percent(x)")
savefig(plotHistogram, "out/plot-histogram.svg")

it works now. Thank you very much!

The only issue left is the exported image height and width which seems to cut the xlabel and ylabel. lookin at savefig help, it does not show any config for that.

view this post on Zulip Notification Bot (Mar 26 2023 at 19:44):

Yuu Yin has marked this topic as resolved.

view this post on Zulip Daniel González (Mar 26 2023 at 19:53):

Weird; when I run the code, the SVG has the labels as well!

view this post on Zulip Leandro Martínez (Mar 28 2023 at 20:24):

As a side note, you don´t need any of those ::AbstractVector annotations , and usually in Julia we separate values with commas (although what you did is not incorrect, just not common).


Last updated: Oct 02 2023 at 04:34 UTC