I have been using pandas, matplotlib and seaborn for data visualisation but I can't figure out how to permanently change the axes limits? I will show you what I mean below:
I want the y axis to go from 0 to 300 and the x axis from -4 to 4 (so that the background grid is complete, none of the squares are cut off).
In general I want the following:
Let the step on the y_axis be z (so 50 in the case above). Then, matplotlib automatically stops the y axis at y_max (maximum y value from the data).
This y_max lands in between kz and (k+1)z, for some positive integer k (in the case above, it lands between 250 and 300, so 5*50 and 6*50, so k=5). Now, I want the y axis to stop at (k+1)z and not y_max.
And similarly for the x-axis.
I know that I can set the y limits and x limits manually for each plot, but is there a way I can somehow permanently get matplotlib/pandas/seaborn to automatically create the figures in such a way?
I tried looking at the rcParams on matplotlib but couldn't really see anything of use.
Related
Say I have data graphed in an xy scatter with straight lines and markers. Data are plotted at (1, 3), (2, 4), (3, 0), and (4, 0). The last two data points are directly on the x axis. To fix this, I want the x axis to be slightly below y= 0.
Here's what I've tried:
Setting the min-y value to a negative number (e.g. -1). I then set the x axis to cross at a number greater than y = -1 (e.g. y= -.02). While this drops the x axis (i.e. floats the zero) as desired, the y axis and negative y-axis values up to -1 are shown on the graph. Typically to cover this area up, I add a white shape with no border. This is neither elegant nor works well when set up in VBA to be used with data sets of various sizes.
When I set the min value to y=-.02 and the x axis to cross at y= -.02, I don't have to worry about the negative values on the y-axis, but the major interval changes to .8, 1.8, 2.8, etc. If I wanted to change the major interval to 0.5, 1.0, 1.5, etc., I'd need to set the min value to -.5, which is far too large when I only want the data points to be slightly above y=0.
Any thoughts?
The regular axis formatting options won't do what you want to achieve, so you need a workaround. For example:
Hide the X axis altogether by formatting it to have no line. Use a new data series with two points. The first point is X=0, Y=-0.02, the second data point is x=the max of the other two series (formula) and Y is the same as the first data point.
Format this series as a line without markers and use it in lieu of the X axis. You can even make the position of this fake X axis dynamic by calculating the Y value from your data, if you want.
This will work with data from the grid, so you don't need to manipulate with VBA, but you could place the series with VBA instead, if you want.
If you need more help implementing this, leave a comment and I'll add more detail.
i've got a data set that is of a vector f(x,y,z). Formatted as fx fy fz x y. This data set is of a crystal lattice and it's associated reciprocal lattice. The coordinates x y are in a non orthogonal basis. Such that x and y are unit vectors x=(1,0) y=(0.5,sqrt(3)/2). I'm trying to plot a set of 3 heatmaps one for each component of f. My issue is that I can seem to change the x and y axis such that they are the unit vectors above. Is there a way to make non-orthogonal/perpendicular axes in gnuplot? If not does anyone have any ideas on how to represent this data set?
Thanks in advance
What you can do is not change the axes, but apply a change of variable from your columns 4 and 5 to the cartesian coordinates x,y:
ex_x=1; ex_y=0
ey_x=0.5; ey_y=sqrt(3)/2
splot "file.dat" u (ex_x*$4+ey_x*$5):(ey_y*$4,ey_y*$5):1 with pm3d
1-How can I rotate my plot so y would be the new x axis and vice versa?
2- Change the maximum value of y axis from 60 to 100.
The plot is created by this script in the terminal :
set palette grey
plot 'color_map.dat' matrix with image
You can exchange the x and y axes with the using modifier. (Just like for ordinary plots, except that for matrix data, columns 1 and 2 are not in your data file, but are inferred.)
plot 'color_map.dat' matrix using 2:1:3 with image
If you actually just want to change the maximum value on the y (new x) axis, you would use set xrange[:100]. But it sounds like you might actually want to scale the data itself, in which case you could use
plot 'color_map.dat' matrix using ($2/60.*100):1:3 with image
Try help plot matrix for more details.
How can I have y axis values with 2 different decimals without using VBA?
I have values in y axis (0.01, 0.10, 1.00, 10.00, 100.00).
I want to change as follows ( to have 2 different decimals): 0.01, 0.10, 1.0, 10.0, 100.0.
If the Y axis on your chart shows values that are in the vicinity of 100, then values in the vicinity of 0.01 will be pretty hard to spot.
Even values less than 10 will not show as a significant blip. What difference does the Y axis label make for units that are not showing, anyway?
If you want to make such fine a distinction, you will want to use two different charts from the outset.
Right click on your y-axis, then click Format Axis. Under Axis Options, check Logarithmic scale.
I am quite new to gnuplot. And I've got problem with secondary y axis. When I try to plot two curves into one graph with two different y axis, the second one is moved down a little bit. I mean that if you draw a straight line parallel to the x axis at y1 = 0, you get different y2 values. I want both y axes to start at the same point y1=0 ~ y2=0.
Here is the picture better describing my problem: