Reputation: 63
I am trying to plot an histogram with the following script:
for i = 1:100
edges(i) = i * 10;
end
[n] = histc(x, edges);
bar(edges, n, 'histc');
When I try to set the axis to a log scale using
set(gca, 'xscale', 'log')
I get the following message
warning: opengl_renderer: data values greater than float capacity. (1) Scale data, or (2) Use gnuplot
The data for the histogram (x
vector) is the column mq135
of this csv file: https://github.com/pedroscaff/sensor-platform-data-analysis/blob/master/data/prenzl-tempelh.csv
I couldn't find a way to change the scale of the axis to log, any ideas on what might cause this issue? The message is pretty clear about the values, but it does not make any sense to me and plotting a histogram using plot.ly worked out of the box.
Thanks!
Upvotes: 2
Views: 2456
Reputation: 8091
Are you really sure you want the xscale as log and not the yscale? This uses hist
but with yscale set to log
base_url = "https://github.com/pedroscaff/sensor-platform-data-analysis/raw/master/data"
fn = "prenzl-tempelh.csv";
if (! exist (fn, "file"))
urlwrite (fullfile (base_url, fn), fn);
endif
# skipp headerline, extract only mq135
mq135 = csvread (fn, 1, 0)(:, 2);
hist (mq135, 0:20:1000);
xlabel ("MQ-135 gas sensor raw data?")
set(gca, 'yscale', 'log')
set(gca, "xtick", 0:100:1000)
grid on
print ("out.png");
gives
Upvotes: 2