Related
I'm trying to plot some data in seaborn where the x values are percentages*100 as floating point numbers (ie 90.909). When I make the plot:
fig, ax = plt.subplots(figsize=(10,10))
ax = sns.stripplot(df_12['% ident'], df_12['length'], jitter=True)
The decimals in the floating points make the X axis unreadable:
Initial Plot
I would like to set the x axis to show only whole number multiples of 5 (ie 80, 85, 90, 95, 100).
One method I have tried is the following:
fmt = '{:0.0f}'
xticklabels = []
count = 0
for item in ax.get_xticklabels():
count+= 1
item.set_text(fmt.format(float(item.get_text())));
xticklabels += [item];
ax.set_xticklabels(xticklabels);
This succeeds in changing the axis values to integers, but the axis looks busy. The numbers shown are also inconsistent between similar datasets.
Second Plot
I would like to reduce the total number of values shown on the axis. I have tried to use
ax.xaxis.set_major_locator(plt.MaxNLocator(5))
Or similarly
ax.xaxis.set_major_locator(plt.MaxNLocator(5))
ax.set_xticklabels([80, 85, 90, 95, 100])
Which give outputs similar to this:
Third Plot
If you compare this to the previous plot, you'll notice the x axis labels no longer relate to the points plotted. How do I set the values of the x axis while still keeping them related to the points plotted?
Other things I have tried:
ax.set_xlim(75, 100)
This and any variants result in a blank plot.
ax.set(xticklabels=[75,80,85,90,95,100])
Does the same thing where the axis labels don't match the data.
ax.set(xticks=range(75,101), xticklabels=[75,80,85,90,95,100])
Results in all the data points stuck on the left side of the plot with all the axis labels overlapping on a single tick on the right.
ax.xaxis.set_major_locator(ticker.MaxNLocator(integer=True))
This doesn't change the axis values to integers, and also appears to cause the axis to no longer correlate with the data.
I need Y axis ticks format in multiples of 500's
What I have is
http://i60.tinypic.com/104500w.jpg
What I need is
http://i58.tinypic.com/bfhod5.jpg
Solved.
I added the below property to the graph:
vAxis:{ticks: [0, 500, 1000, 1500, 2000, 2500, 3000, 3500]}
I have a specific set of values for example :
[1, 4, 12, 32, 150, 250]
How can I display them on a x axis but with the same gap between each ticks ?
For the momvent by specifying tickvalues to the axis with a linear scale I obtain something like that
1-4--12---32-------150----------250
But I am searching to obtain something like that :
1--4--12--32--150--250
Thanks for your help
If I have matrix/data with line intensity values:
e.g.
0, 1, 2, 3, 4, 5, ..... M (where intensity value is gradually changing)
or
any random order of values
So if I use the first intensity set of data, (0, 1, 2, 3, 4, 5, ..... M), my line color should be gradually turning black to white. If I remember correctly, 0 is used to represent black and 255 is used to represent white? I would like to use a data of intensity values to draw 3D line with changing color/intensity.
How can I draw a 3D line with changing intensity/grayscale? I would appreciate any advice or recommendation.
You can use the 3D colored line plot tool from the file exchange and change the colormap to whatever you need.
I am developing some routines in Octave and need to display an image, then plot a curve on top which will hopefully overlay some image features.
However, I cannot work out how to match the origin/scale of the image and the plot. For example, given a 1024x1024 pixel image I can do:
a=imread('image.png');
x=linspace(1,1024,100);
y=x;
imshow(a);
hold on;
plot(x,y);
But the line is not scaled to the image and does not start at a corner. (I know that the image and plot should have origins in different corners). When I examine the graphic coordinates from the cursor position, the image is clearly not at the origin, so I guess this is the basis of the problem.
Use image() instead of imshow() in this case
a = imread ('image.png');
x = linspace (1, 1024, 100);
y = x;
image (a);
hold on
plot (x, y);
axis square
You can plot functions over images this way:
Create an image called stuff.jpg like this, any size is possible but I made mine roughly 6x6 pixels so I could test:
You can plot functions over other functions this way:
octave> x = 0:1:5;
octave> plot(x, (3/2).^x, "linewidth", 2, "color", "blue");
octave> hold on
octave> plot(x, 2.^x, "linewidth", 2, "color", "red");
octave> plot(x, factorial(x), "linewidth", 2, "color", "green");
octave> plot(x, x.^3, "linewidth", 2, "color", "black");
octave>
For me it shows this:
Found that here, it has a walkthrough:
http://ericleschinski.com/c/algorithm_complexity_big_o_notation/
Which plots my power level given my age. It's already over nine thousand.
The problem with image is that it puts (0,0) (rather (min_x,min_y)) at upper-left while we usually expect (0,0) to be at bottom-left.
Also it only uses max and min values of the x and y vectors so doing y(end:-1:1) doesn't work.
im = imread('file.png'); %read the file
image([xmin xmax],[ymin ymax],im(end:-1:1,:,:)); %put the image on the screen upside down
axis('xy'); % flip the image by putting (0,0) at bottom left. Image now right side up
axis('square'); if you want to aspect ratio of the image to be 1:1
hold on;
plot([xmin xmax],[ymin ymax]) % this should draw a diagonal from bottom left to upper right.
% plot whatever you want to overlay