White space between data and axis when using pcolor in octave - plot

I am trying to create a colorplot using pcolor. I want to use "shading interp" so am not using imagesc(). However when I set the axis manually the plot has white space between the data and the axis.
I want to zoom into one section of the data rather than the whole image. (This problem does not occur when the matrix and using "axis("tight") )
Thank you in advance for your help
The code I am using is :
clf
load x.dat;
load y.dat;
load 15-1-14_E2_lam_7410nm.txt
x=x;
y=y;
A=X15_1_14_E2_lam_7410nm;
A=rot90(A);
h=pcolor(x,y,A);
shading interp
set(h,"EdgeColor",'none');
axis([60 90 -20 20])
#axis("tight")
colorbar

I believe the white space at one or more axis edges is because your data does not go fully to the edge of the frame (or the axis) you are setting. This can happen frequently when using something like meshgrid() to set the frame from -L to L in steps dl but then your data may start at -L and only go to, say, L-dl.

Related

rectangles on Grace plots

I have been using Grace (xmgrace) plotting for many years. I recently had an important idea for my work, and it involves rectangles on my plots. Grace supports rectangles (called "boxes"), but when I use a filled "box" it blocks my data curves. I want the curves to show over the filled rectangles. This is driving me nuts. Does anyone know how to put the filled rectangles in the background so they don't block data curves? Thanks.
Unfortunately there is no option in the xmgrace graphical interface that allows you to modify the z order of drawing objects such as boxes:
I also saved the graph as an .agr file and viewed it in a text editor. There doesn't seem to be any flag within the file format to modify z position, either.
Same story if you save a parameter file and check it in a text editor.
So it looks like it is really not possible in xmgrace.
One workaround would be to print to a postscript, EPS or SVG file and open it inside a vector graphics program such as Inkscape (results vary, you might need to experiment with filetypes to see which works best). Then you can easily alter the z order of objects.

(Over)plotting points on a line plot

I am trying to plot individual data points on a line plot I already made as follows:
p=plot('3.29*exp(-17.4*(x^2))-0.908',xrange=[0.,1.],yrange=[-1.,1.5])
I first tried overplotting a point like this but nothing appears on the graph
estimate1=plot([0.549],[0.755],overplot=1)
When I give the plot function two points to overplot by adding another set of x and y values in input vectors, it connects them.
estimate=plot([0.349,0.9595],[0.555,0.9995],overplot=1)
How can I (over)plot the points without them being connected?
You should be able to set linestyle = 6 which will plot without the line.
I found a way around the problem I was having. After choosing a symbol for the points I wanted to show, I simply set the transparency of the line connecting them to 100 and the symbol transparency to 0.
estimate1.symbol='diamond'
estimate1.transparency=100
estimate1.sym_transparency=0
The work around is not elegant, but it works.

Plotting an image next to a ruler using r

What I would like to do is make a series of plots that combine an image with a scale that is related to the height of the image, but is multiplied by a factor.
So far I've been able to make a plot using the following code:
library(imager)
im <- load.image("ZAB17_4.png")
plot(im)
Image is attached here
But what I would like to do is to have the y-axis be scaled by a value:
pixel_size <- 0.0596
I would also get rid of the x-axis. (xaxt="n" doesn't seem to do the trick). Ideally, I would like the Y-axis to be directly adjacent to the image. I've been trying to poke around with scales in the plot function, but haven't found what I need to do this, but I'm sure there is a simple solution.
*Edited to add image. I should note that the goal is really just to add a scale to the image. The pixel size represents the size of each pixel in reality in mm. I basically want to add a ruler along the side of the image. Maybe r is not the best tool for this, but I plan to also plot data taken from the imaged object and plot it alongside.
Any help is appreciated.

How to keep previous plots and windows in Gnuplot?

I have some problems of using gnuplot. I just begin with it.
(1)What is the command for keeping the previous plot when I plot new data? Do I have to plot the old data and the new data at the same time?
(2)What is the command for open a new window while keep the old ones? Do I have to set the window's id by using, e.g.,
set terminal wxt 3
, before each plot?
Can anyone give me some help or some good references?
Usually, to plot several data set you would use
plot 'data1.dat', 'data2.dat'
You could also use replot to add one of the data sets later
plot 'data1.dat'
...
replot 'data2.dat'
To open a new window, you must use the window's id like with set terminal wxt 2. The old windows stay open, but you cannot interact with them anymore (zooming, scrolling etc.). See also the discussion to the quesiton Two interactive windows in Gnuplot with wxt terminal.
You already wrote the answers of your questions.
1.: You can use the replot command:
plot sin(x)
replot cos(x)
but this just expands to
plot sin(x), cos(x)
So, it replots all data and does not just add the cos(x).
2.: Yes, you can also switch between the windows to update the plots. But note that settings like ranges and labels are not stored per window / plot, but globally. If they are different for different plots, you have to change them every time.
You may also have a look at "set multiplot" to put several plots on one window / picture. But it is not so nice for interactive plotting, as you will notice.
Also, output terminals supporting multiple pages like pdfcairo will add a new page for each plot.

Plot 3D mesh in Maxima without colored surface

I have a 1-dimensional list x in Maxima with 16 different elements, and plotted every possible product of two elements as a 3D plot:
g(u,v) := float('x[round(u)]*'x[round(v)]);
plot3d(g(u,v),[u,1,16],[v,1,16],[grid,15,15]);
Which yields this result:
http://i.stack.imgur.com/uKwfe.png
My desired result is having only the contour lines, i.e. the mesh. I don't want the coloured surface.
This seems like a trivial task, but the manual is very unclear on this. It says that usually, you already have only the mesh, but this isn't the case.
Using wxMaxima 12.04.0 on Windows.
Looks like the key is to get the Gnuplot output file to contain the line
set style data lines
Maxima has its own idea about "set style ..." which you can see by
set_plot_option ([plot_format, gnuplot]);
and then inspecting the output file ($HOME/maxout.gnuplot by default). I don't know how to convince Maxima to output a different style command. As a last resort you could edit maxout.gnuplot by hand.
g(u,v) := float('x[round(u)]*'x[round(v)]);
plot3d(g(u,v),[u,1,16],[v,1,16],[grid,15,15], [palette, false]);
The [palette, false] option turns off surface coloring and draws only the mesh. But you'll still get hidden line removal, which Maxima automatically turns on.
To get a transparent wire mesh, do this:
plot3d(g(u,v),[u,1,16],[v,1,16],[grid,15,15], [palette, false],
[gnuplot_postamble, "unset hidden3d;"]);

Resources