I have a plot in excel bar graph as shown in the image. But I want the Y axis data to be held at it's value until the next discrete sample in X axis .i.e the value of Y axis is 160.8 at X=1, and I want this value to be held until X=2 where the value of Y changes to 2. How do I do this?
Edit 1 - I tried following this tutorial and it worked - https://trumpexcel.com/step-chart-in-excel/
But I had to format the X axis cells to date format. I want the same to work when X axis format is a number.
Related
I have a boxplot that looks like this:
My x axis has 2 variables (0 and 1) which I want to rename "Low" and "High" respectively but I just can't seem to find the code for this.
This is the code I used for the boxplot: data$meansplit is the vector on the x axis I want to rename
boxplot(data$threshold_SDT ~ data$meansplit)
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.
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 have an excel scatter plot which is working for the Y axis but not the X Axis. If I change the Y values the data point moves accordingly. However, the X axis seems to be fixed in positions. The closest thing I can identify to logic is that the first number in the series is the X axis as 1, the next is 2, 3, 4, and so on
I would like (5.6,3) to show up at (5.6,3) not (1,3) because it's the first in the series.
Example for X axis theory:
Series
X ------ Y ------ graph placement
.6 ----- 3 ------ (1,3)
1.2 ---- 3.4 ---- (2,3.4)
.8 ----- 5.2 ---- (3,5.2)
notice the X coordinates 1,2,3 are moving sequential with their placement in the series.
Example for Y axis working:
(1.333,1) is placed at (3,1) on the plot. If I change it to (1.333,2) then it goes to (3,2). The X Axis changes do not move the point.
I give up. On the right is a chart that I think represents what you are seeing, driven by the data as shown which includes a single inverted comma I prefixed 1.333 with. On the left I overlaid an image of the chart I see without that inverted comma - and I think represents what you want:
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.