Octave: transparent surfaces, how? - gnuplot

I try to plot transparent surfaces in Octave using facealpha set to 0.2.
Ok, I have read that this is not implemented, but if I run this code, I get
a plot with a transparent plane.
`
close all;
clf reset;
cla reset;
graphics_toolkit("gnuplot");
colormap(bone(64));
a1=-1;b=1;h1=0.01;# making a mesh
x2=a1:h1:b;
nz2=length(x2);
[X1,Y1]=meshgrid(x2,x2);
Z1=zeros(nz2,nz2); # function equal to zero on the mesh
s1=mesh(X1,Y1,Z1);
view([120 40]);
# properties of the faces and edges
set(s1,'edgecolor','none')
set(s1,'facecolor','black')`
set(s1,'facealpha',0.05)
hold on
scatter3([-0.5 0],[-0.5 0],[0.5 -0.5],8,'k','.');# two points one above # and one below the plane
# print to eps
print -deps testsurface.eps
`
this figure pops up and if I save it the plane remains transparent:
but if I look at the printed version with the print command, I get
this with a non-transparent plane, one point is now invisible:
Is it possible to get the transparent plane with the print command or do I have always to save the pop-up plot window?
I am Edit:running Octave 4.02 on Xubuntu 16.04.
EDIT: If I try it with fltk, same result, with qt the plane vanishes.

Related

How to download 3d plots with a specific camera angle in jupyter notebook?

I am using jupyter ipython notebook to generate 3d plots using matplotlib. I can get zoom and and pan options with the %matplotlib notebook command. I would like to download the plots with a specific camera angle that I choose with the pan/rotate option. Using savefig saves the default camera angle of the plot. How can I do this?
If you take the mouse to the up right-hand side of the plot, some options show up. If you press the first one (with the shape of a camera), it will save your plot with your desired angle to the download folder of your laptop.

Haskell Diagrams Graphviz Gtk Display alignment and scaling

I want to display a graph layed out by graphviz (via Data.GraphViz) in a Gtk window. The code I have does not automatically center the graph or size the diagram. I have setup a github repo with an example (see src/Main.hs at https://github.com/avras/diagrams-gtk-graphviz-example. I get the following output.
If I try showing a circle of radius one, I get the following output (which is expected). The code for this example is at src/Circle.hs in the same github repository. Main.hs and Circle.hs differ only in the diagram which is rendered (afaict).
How can I get the graph to be centered in the window with the right width automatically calculated?
I had to play around with the argument to mkWidth to get this picture. Also without setting lw 0.005 the result was the following. The line width seems to be very large.
EDIT Here is the result after the fix suggested by Joachim Breitner.
This is a guess, but I assume that the circle is centered on the origin (0,0), and the diagram is put in the unit square (between (0,0) and (1,1)).
I would guess that if you remove the line
GRC.translate (w/2) (h/2)
in Main.hs it will work.

Octave with gnuplot adds edges in a mesh

When doing surf in octave I get the following results, with different graphics_toolkit.
Run:
surf([1 2 ; 1 2 ],[1 1; 2 2],[6 2 ;4 6],'FaceColor','interp')
To change graphics toolkit you may need to restart octave and run:
graphics_toolkit ftlt|gnuplot
I want gnuplot (B) to display edges as in fltk (A). For some reason I dont understand, gnuplot adds a lot of edges in the middle of the plotted faces (B) which I want to remove.
Using 'EdgeColor','none' (C) I'm able to remove all edges, although I want to keep the edges between datapoints (ie, those shown in A).
An option would be to use fltk, but I prefer the presentation (coulouring and shape) and latex support gnuplot provides.
So: How to make gnuplot show only the edges between datapoints (ie. those in A)??
A) Using default fltk:
B) Using gnuplot:
C) Using gnuplot with 'EdgeColor','none'

Octave + Gnuplot rendering image upside down

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

SetWorldTransform() and font rotation

I'm trying to display text on a Windows control, rotated by 90 degrees, so that it reads from 'bottom to top' so to speak; basically it's the label on the Y axis of a graph.
I got my text to display vertically by changing my coordinate system for the DC by using SetGraphicsMode(GM_ADVANCED) and then using
XFORM transform;
const double angle = 90 * (boost::math::constants::pi<double>() / 180);
transform.eM11 = (FLOAT)cos(angle);
transform.eM12 = (FLOAT)(-sin(angle));
transform.eM21 = (FLOAT)sin(angle);
transform.eM22 = (FLOAT)cos(angle);
transform.eDx = 0.0;
transform.eDy = 0.0;
dc.SetWorldTransform(&transform);
Now when I run my program, the rotated text looks different from the same text when it's shown 'normally' (horizontally). I've tried with a fixed-width (system) font and the default WinXP font. The system font comes out look anti-aliased and the other one looks almost as if it's being drawn in a 1-pixel smaller font than the horizontal version, although they are drawn using the same DC and with no font changes in between. It looks as if Windows detects that I'm drawing a font not along the normal (0 degrees) axis and that it's trying to 'optimize' by anti-aliasing.
Now I don't want any of that. I just want to same text that I draw horizontally to be drawn exactly the same, except 90 degrees rotated, which is possible since it's a rotation of exactly 90 degrees. Does anyone know what's going on and whether I can change this easily to work as I want? I'd hate to have gone through all this trouble and finding up that I will have to resort to rendering to an off-screen bitmap, rotating it using a simple pixel-by-pixel rotation and having to bitblt that into my control :(
Have you tried setting the nEscapement and nOrientation parameters when you create the font instead of using SetWorldTransform? See CreateFont for details.

Resources