[Scilab-users] filled contour plot

Claus Futtrup cfuttrup at gmail.com
Sun Jan 21 15:55:42 CET 2018


Dear Scilabers

In my endeavours to plot radiation pattern for loudspeakers, besides polar
plot, I'm also attemptning to view my data with a sonogram (2D contour
plot). Here I ask for help to manage the colors of the plot. Here's the
code (same reduced data as before):

// Test data
frequencies = [200 2000 20000]; // Hz
angles = [0 30 60 90 120 150 180]; // degrees - convert to radians!
mag00 = [69.253448 92.163385 87.414209]; // on-axis freq-response
mag30 = [68.461357 90.569082 76.073549];
mag60 = [65.842262 90.745621 74.152067];
mag90 = [59.420658 80.893365 55.975304];
mag120 = [52.505173 80.795915 44.363582];
mag150 = [53.829987 59.793715 42.443964];
mag180 = [55.650341 73.457973 55.608187];
magnitudes = [mag00' mag30' mag60' mag90' mag120' mag150' mag180'];
// 3 freq x 7 angles = 21 data points, put into a matrix.
// In the complete dataset there's 183 frequencies and 72 angles.

negative_angles = -angles(2:7);
neg_angle_magnitudes = magnitudes(:,2:7);

angles = [angles negative_angles];
magnitudes = [magnitudes neg_angle_magnitudes];
[angles idx] = gsort(angles,'g','i');
magnitudes = magnitudes(:,idx);

// Plot example:
contourplt = scf();
xset("fpf"," "); // Floating Point Format
contourplt.color_map=jetcolormap(5); // blue = cold, red = hot :-)
contour2d(frequencies,angles,magnitudes,50:10:90,logflag="ln");
contourf(frequencies,angles,magnitudes); // FILL with color
contour2d(frequencies,angles,magnitudes,50:10:90);
legends(string(50:10:90),1:5,"lr");

P.S. "funny" - I'm plotting contour2d first, because then I can specify
logflag and the numeric labels goes bye-bye. If I execute contourf first, I
cannot use log-x-axis. contourf complains that Nax cannot work with
log-x-axis data, but contourf fills the plot anyway. I then redo the
contour2d to get my contourlines back (because contourf paints over them).

Help how to get the right colors in the plot would be highly appreciated.
In particular contourf complains: Colormap too small

Can I manage colormap for contour2d and contourf separately?

Best regards,
Claus
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20180121/462554ac/attachment.htm>


More information about the users mailing list