Axis value with different decimals in excel - excel

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.

Related

Permanently changing the range of the axes using matplotlib?

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.

Hide y axis below a certain x value when floating zero

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.

Select data within the area of a series in Excel

Ok, so I have two data series graphed, like so.
These are two scatter plots, based on x and y values, that are produced using a combo chart. The orange scatter plot is an ellipse whose calculation is based upon aspects relating to the purple scatter plot. I have made the orange ellipse in order to... well... select the part of the purple scatter plot that I want to do other things with. Problem is, I don't know how to actually select the data points this area refers to.
The data for this chart is based upon four columns: A,B (forming the purple plot) and C,D (forming the orange plot). Reordering the columns makes little difference.
Implementing Anger's proposed solution below, all instances seem to return true. Also, there happen to be more scatter plot rows than there are ellipse rows, so I'm not sure how to solve that for the sake of comparison.
If you specify the equation of the ellipse (center point and semi-major/minor axes), you can use the equation of the ellipse to flag points that are inside or outside.
if( ((Ex-x)/Lx)^2+((Ey-y)/Ly)^2 < 1, "INSIDE", "OUTSIDE")
Where Ex, Ey are the coordinates of the ellipse's center; x, y are your data point's coordinates, and Lx, Ly are the semi-major and semi-minor axes.
Just by eye, I would say Ex = 1.8, Ey = 1.21, Lx = 0.6, and Ly = 0.5.

Python matplotlib with percentile data on X axis

I have probably a simple issue, but I spent more than one hour checking both in here and on google without finding the solution I need.
My simple goal is to plot the histogram for the values stored in a dataframe column.
The problem I face is that I need the x ticks used to define the bins to correspond to percentile values
perc = [0.10, 0.20, 0.30, 0.50, 0.70, 0.90, 1.0] # percentile values
This implies the histogram plot will have non-uniform bin widths.
I tried this solution Percentiles on X axis with matplotlib but that gives me ton of vertical bars and not just bins corresponding to my percentile levels.
I also saw a similar question here python plot hist(graph) with percentile but it doesn't have any answers.
Addition to my question.
I'm trying the following code but it doesn't really do what I need.
data = df["sales"].values # this is a an array with 58k values, 99% of which between 100 and 5000 and 1% of which between 1mln and 2mln
perc = [0, 0.10, 0.20, 0.30, 0.50, 0.70, 0.90, 0.99, 1.0]
perc_values = np.percentile(data, perc)
histaa = np.histogram(data, bins = perc_values)
plt.hist(histaa, bins = perc_values);
The bins I obtain has not the same width and the plot has a big empty region.
Adding also a screenshot.
I wonder If anybody could help.
Many thanks

gnuplot how to set tics format by power of 10

I have a plot with:
xtics = {0, 2000, 4000, ..., 20000}
and I would like them to be shown as:
0 2 4 ... 20
x 10^3
Is there any way to do so?
You can do so by setting a label at the appropriate position:
set label 1 "× 10³" right at graph 1, -0.05
This would place the text × 10³ right aligned with the right border of your plot and somewhat below it. You probably have to adjust the vertical position (−0.05) a bit depending on your plot.
However, I recommend against indicating factors like that and suggest to incorporate them in the axis label and use set xlabel "amount [10³ potatoes]" for example. The kind of labels you want to use are easy to miss and fortunately not common anymore.

Resources