2

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!

djscuf
  • 63
  • 6
  • You are setting the `x` scale to log on a bar plot? That seems pretty weird. The bars would be squeezed in. Perhaps the bar edges are made to be so small that the renderer complains. You sure you dont want `yscale` to be log? – Ander Biguri Aug 18 '17 at 15:48
  • and btw, creating `edges` this way is very.... uncommon. Use `edges = 10:10:1000` – Andy Aug 19 '17 at 07:42
  • thanks for the quick replies! I did want to set both axis to log, both axis had a big range of values! @Andy I haven't used octave in ages and I just needed some simple scripts like this one, I did everything very intuitively hehe, thanks for the tip! – djscuf Aug 22 '17 at 20:18

1 Answers1

2

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

hist plot, yscale log

Andy
  • 7,931
  • 4
  • 25
  • 45