help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Using Octave functions in gnuplot and doing filledcurves?


From: Aivo Jürgenson
Subject: Using Octave functions in gnuplot and doing filledcurves?
Date: Sun, 2 Apr 2006 08:14:42 +0300 (EEST)

Hello,

I'm a little puzzled over this and could use some example or guidance.

I have developed some custom functions in Octave to handle arithmetics with random variables and now I would like to visualize them and create some nice graphs. To start with, I would like to create a graph of normal_pdf(x,a.mean,a.std) and then fill the area in the graph, where quad('normal_pdf',a.k_1,a.k_2) equals to a.p. This should be some part below the probability density curve and such graphs are quite common in calculus course, where you are learning to calculate the area between the function graph and x-axis with integrals. So, nothing too strange, I hope.

Also, I would like to use LaTeX fonts on the graph, therefore the LaTeX notation.

I can successfully create a graph of PDF with the following Octave commands:

x=-10:0.01:10;

# Random variable is defined with the range estimation and probability of # variable having values from this range

a.k_1 = -1;
a.k_2 = 3;
a.p = 0.8;

# Calculate the mean of the random variable. Just replace with
# a.mean = 1; for testing
a.mean = atree_normal_mean(a);
# Calculate the standard deviation of the random variable. Just replace # with a.std = 1.56061; for testing
a.std = atree_normal_std(a);

label = sprintf(";$X \\sim N(%g, %g)$;", a.mean, a.std);

gplot(x,normal_pdf(x,a.mean,a.std), label);

__gnuplot_set__ format xy "$%g$";
__gnuplot_set__ xlabel "$X$";
__gnuplot_set__ ylabel "$\\Pr[X = x]$";
__gnuplot_raw__(sprintf("set xtics (%g, %g, %g);", a.mean, a.k_1, a.k_2));
__gnuplot_raw__("set style function filledcurves x1;");

replot;

The problem is that the "set style function filledcurves" command doesn't do anything. I have tried with "set syle data ...", "... filledcurves closed", and other options, but no luck. No error message is returned either, just no part of the graph gets filled.

Has anyone done similar things or could give me some hints how to get my filled graph easily? I hope there is something I have missed and such graphs can be made with Octave and GNUplot.

Aivo Jügenson, address@hidden

reply via email to

[Prev in Thread] Current Thread [Next in Thread]