Octave + Gnuplot rendering image upside down - gnuplot

I am displaying data using function imagesc(). If I set fltk as graphics_toolkit image is displayed correctly.
Can't post images directly(low reputation) http://i.stack.imgur.com/ARiwF.png
If I use gnuplot as plotting program image is rendered upside down.
fltk is unusable for me because its window isn't responding while function in octave is running. I also tried plot sine and it was correct plotted through fltk and gnuplot too.

There are at least two workarounds:
Use axis("xy") or axis("ij") to control the orientation of the y-axis, as decribed in the axis documentation
Use set(gca, "ydir", "normal") or set(gca, "ydir", "reverse"), as decribed in the axes properties doc

Related

how to keep proportions in jpeg image when importing it to rstudio

Is there any way to import a jpeg image in Rstudio or R and keep its original proportions? The following way used to work for me, but not anymore.
require(jpeg)
image=readJPEG(system.file("img", "Rlogo.jpg", package="jpeg"))
plot(1, type="n", xlim=c(1, ncol(image)), ylim=c(1, nrow(image)))
rasterImage(image,xleft=1, xright=ncol(image), ybottom=1, ytop=nrow(image))
Thanks in advance.
Make sure your underlying plot has a fixed aspect ratio of one.
plot(1, type="n", xlim=c(1, ncol(image)), ylim=c(1, nrow(image)), asp=1)
Otherwise the plot will just stretch to whatever aspect ratio the graphics window is, and the raster is "glued" to the plot such that it stretches too.

Can I plot some points over an image?

I wanted to get a scatter plot but the constraint is to plot these points over an image with same dimension as the range of points. Is is possible? If yes which library is good to start with? I tried using gnuplot but it is causing problems. For now I have a code which was stated here but didn't work. I tried using a bitmap image with the points to be plotted in data1.dat file and used the gnuplot script which is stated in the link
set terminal pngcairo transparent
set output 'Figure1.bmp'
plot "Co_ordinates0.dat"
set output

octave plot over image: image disappears when scrolling or zooming (gnuplot)

I can successfully plot over an image but then as soon as I scroll or zoom, the image disappears (the plot stays displayed).
I have tried plotting images by using the exact code here. I Also tried using by using imread/imshow,or imagesc instead of imshow, the behavior remains the same (image disapearing).
Not sure whether this is related or not but when using imread I get the following warning "|warning: your version of GraphicsMagick limits images to 8 bits per pixel"
I am using octave 3.8.2 and gnuplot (5.0 patchlevel 1) on os X 10.11.1
Any suggestion on how to keep image displayed while scrolling or zooming?

Set legend text's HorizontalAlignment to left in octave

I have legend text that in matlab behaves as
set(gcf,'DefaulttextHorizontalAlignment','left');
now I am attempting to replicate this in octave, but for some reason octave seems to ignore the above command.
I am using cygwin Xwin octave and GNUPlot.
(I am not trying to move the text to the other-side of the "line" legend('left'))
Doing some tests, it turns out that I can set the property, but it isn't affecting anything.
LegendHandle = legend( phvec, legendvec, 'Location', 'NorthEastOutside' );
legtxt=findobj(LegendHandle,'type','text');
get(legtxt(1),'HorizontalAlignment') %% returns left
It seems Gnuplot supports the option to change the legend horizontal alignment, but Octave doesn't provide the access to this function in Gnuplot (although it works with FLTK). You simply can't do anything about it, except filing a feature request on the Octave tracker.
Source: http://octave.1599824.n4.nabble.com/set-horizontalalignment-for-legend-text-td2218246.html
So yes, there's currently no solution to left align the legend text using gnuplot, the only thing you can do to remove this awful blank space is, as you said, to use legend('left') to swap the text to the left of the symbols.
I can replicate your problem but only if using gnuplot. It works with other graphics toolkits.
While gnuplot was Octave's default graphics toolkit for a long time, the Octave developers have been slowly replacing it with their own alternative in order to avoid its limitations. I believe recent versions of Octave will already default to fltk but you can change it yourself:
octave-cli-3.8.1> graphics_toolkit fltk
octave-cli-3.8.1> graphics_toolkit # confirm
ans = fltk
octave-cli-3.8.1> x = 0:0.1:10;
octave-cli-3.8.1> figure;
octave-cli-3.8.1> plot (x, [sin(x); cos(x)]);
octave-cli-3.8.1> legend ("long sin", "cos", "Location", "NorthEastOutside");

Alternative to flot where the axes labels are within the canvas

I have been using the fantastic canvas plotting library flot. The selection of graph types is excellent but I want to be able to export the whole graph to an image, including axes numbers, ticks and labels and a the graph title.
Unfortunately only the graph itself seems to be drawn in the canvas, the axes numbers and ticks are in divs. Therefore the canvas toDataURL method does not capture everything.
Can anyone recommend a library with similar functionality which either:
Draws everything within the canvas, or
Has a reliable export to image method
In particular I would like a library which supports the percentiles plot.
Flot 0.8 supports drawing axis labels to canvas using the canvas plugin. I don't know about the chart title - that depends on what plugin or code you're using to do that - but it would be relatively easy to add a draw hook to render that text to canvas.
The only thing Flot can't currently draw to canvas is the legend; that will be added in the next release.

Resources