How to change side of y-axis in histogram? - graphics

If I use the hist command without any specifications or options, I get a histogram, where the only y-axis is located on the right side. I searched the web for options to change it to the left side, but all I could find was about a second y-axis or the title of the axis.

If you run this script
sysuse auto, clear
set scheme s1color
hist mpg
hist mpg, ysc(alt)
you should see
The default in which the y axis is on the left.
An alternative in which it is on the right.
These are standard options for graph twoway documented from help hist under two_way_options, in turn under axis_options, axis_scale_options.
All the help you need is included with the Stata version you are using. Googling is inefficient here.

Related

Reverse abscissa/ordinate axis in wxdraw2d or wxplot2d wxmaxima

By default, the draw/plot function plots y-axis values in ascending order (from bottom to top). In other words, -ve values are at the bottom of the graph and +ve values above the origin (towards the top of the plot). Can we reverse (see the figure attached) this behavior for the individual axis or both?
It is possible in gnuplot, by passing set xrange reverse and set yrange reverse, but wxmaxima does not provide a full interface for gnuplot, however, it seems that direct access may be possible. As from the docs:
2.3.5 Opening gnuplot’s command console in plot windows
On MS Windows, if in Maxima’s variable gnuplot_command “gnuplot” is replaced by “wgnuplot”, gnuplot offers the possibility to open a console window, where gnuplot commands can be entered into. Unfortunately, enabling this feature causes gnuplot to “steal” the keyboard focus for a short time every time a plot is prepared.
Please also note that there is a difference in gnuplot 4 and 5:
The reverse keyword of the set [axis]range command aects only autoscaling. It does not invert or
otherwise alter the meaning of a command such as set xrange [0:1]. If you want to reverse the direction
of the x axis in such a case, say instead set xrange [1:0].

Gnuplot key: sample and title positions

Is it possible to adjust the relative vertical position of the sample in a key
and its title? Running these commands
set terminal pdfcairo
set output 'foo.pdf'
set yrange [-1.2:1.2]
plot sin(x)
produces a plot with a key that looks like this:
I'd like the sample in the key to be a bit lower relative to the title in the key (or the title in the key a bit higher relative to the sample in the key).
EDIT: There seem to be other issues with alignment, not just in the key. This is the whole graphic produced by the commands above, using the latest Gnuplot installed by homebrew on OSX 10.10.5 (Gnuplot 5.2.2, cairo 1.14.12). The same thing is evident on OSX 10.11.6. At least some of the labels on the xaxis seem to be shifted a bit to the right of the tic, and labels on the yaxis seem to be shifted down.
help set key provides you with all necessary details. In your case, probably
set key left
would already help. But there is also the option to tell gnuplot precisely where you want the key to be placed, using
# This places a key at coordinates x = 6.5 and y = 0.8 in the coordinate system:
set key at 6.5,0.8
Another way, rather than playing around with key positions, is also to adjust the range in a way that comfortable space is left for the key, in your case
plot [-10:+10][-1.1:1.2] sin(x)
might help.

"pixel dimension information" when plotting with image in gnuplot

Using gnuplot v5 patch 6 on windows 10 (wxt terminal)
I have a data file of 2D vectors arranged in six columns (x, y, v_x, v_y, v_mag, rho) that I'm trying to plot as a heatmap of v_mag against x and y. The plot generates fine, but it's always coming up with
"No dimension information for 80000 pixels total. Try 200 x 400"
But I have no idea where to specify this in the terminal.
I realise that I can use pm3d map for this, but this doesn't work without setting dgrid3d and that causes problems with plotting dots on top of the heatmap which I'm also doing. I also don't want to generate a matrix file just for the image plot since I need the vector data for analysis later.
In terms of an example, the plot will generate if I literally just write:
plot 'vectors.dat' using 1:2:5 with image, 'dots.dat' with dots
EDIT: added 'set pm3d' to example code
EDIT: example is now minimal code to produce desired plot
EDIT: example data file can be found here
Any help would be appreciated.
After updating my gnuplot to v5.2, this problem has disappeared.

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");

javafx2 center axes on XYChart

JavaFX does not provide a CENTER value for Side so I am trying to center the X and Y Axis by translation:
scanXAxis.setTranslateY(0.5*scanYAxis.getBoundsInParent().getHeight()); // xAxis initially on TOP
scanYAxis.setTranslateX(0.5*scanXAxis.getBoundsInParent().getWidth()); // yAxis initially on LEFT
The result I am getting however are axes crossing at a point that depends on the scene's size instead of (0,0) i.e I can get them crossed at the origin by manually resizing the scene. This is exaclty the reverse of what I am striving for.
Any help would be greatly appreciated!
Cheers
I am using the Axis and I think the design is not friendly. I can't set the axis upside down or right to the left. I used axis.rotate but I have to hack the code for the layout of the contentPlot. Also, the axis can only be set to the left, right, top or bottom. But I want some flexibility, e.g. when I implement parallel coordinates, I can't put it to the place I really want to put it. So I am thinking I have to write my own axis class instead.

Resources