I have a question, I am plotting in python and I put these plots together in Latex. The figure sizes are the same, however, as you can see the plot width and height of the axes of the plot are not the same. Also because figure a has one xlabel (alive or dead), while figure b has two (the numbers range and 'amount of days'.
Anyone has an idea how I can set the width and height of the plot?
I already tried put.figure(figsize(x,y) but that only fixes the figure length, but I need to fix the size within the figure.
Thanks
Related
I am plotting 2D contourf, after which I added some contour for some levels.
CS = ax.contour(XX,YY,Z, levels, colors='k')
ax.clabel(CS, inline=True, fontsize=10)
The above simple lines generate the figures below, where the labels are located outside the plot.
While I can fix the (x,y) values with manual, this will not work as generally as I want.
For example, I can try to fix (x) location, e.g. the center of the xlim, and find (y) values for the corresponding contours of each level. But as you can see in the shown figures, it is not general since the 0.100 contour does not have (x) location inside the plot, which is fixed to the center of xlim in this case.
I am pretty sure there is some way to put the labels inside the plot, but it is hard to find.
Any suggestions will be appreciated.
I am trying to create one plot with one scatter and multiple lineplots.
For the points to be seen well, I need the scatterplot in the front.
However changing the order inside my code doesn't solve this. The
lineplots always cover the scatterplot. Any ideas?
Please help.
Use the zorder parameter when scatterplotting, e.g.
sns.scatterplot(x, y, ax=ax, color='orange', zorder=7)
You may need to adjust the zorder value depending on the number of elements in your plot.
full - clearest image, shows the labels extending out the right of my plot
"zoomed" - highlighting why this is a problem as the plot becomes unreadable when selecting and plotting subset of the x-axis range
I'm working on some data where I have plotted a spectrum and have added vertical lines to specific positions. I have labelled these lines but my problem is that if I want to "zoom in" by decreasing my x axis range, the full list of labels for the vertical lines are still plotted resulting in an unreadable plot.
I iterate through a list of x positions and labels for my vertical lines and plot as follows:
for x_pos, label in zip(list_x_pos, list_label):
plt.axvline(x=x_pos)
plt.text(x_pos, y, str(label), rotation=90)
plt.xlim(2, 5)
So, because my "x values" go > 5 the resulting plot is a tiny figure with a row of the labels extending out from it.
The only solution I can think of is to slice my list_x_pos but this will crate other problems for me so ideally looking to find a way to just show the labels within the range of the plot.
Hope I've made sense!
Thanks,
Olie
You can use plt.text(..., clip_on=True) to force texts outside of the box to not be displayed.
Resize the axes first and then plot the vertical line.
I'm trying to plot using labels with varying font size. For example:
plot "some_data_file" using 1:2:(20-$3) using labels font sprintf("Helvetica,%d",variable)
Or something to that effect. The label's font size should be 20 minus the value in the third column. This line doesn't work, but I think it displays what I'm trying to do. Any ideas?
Look at cities.dem demo on gnuplot.info for a way to do this.
I'll steal the solution there, modified for you:
plot "some_data_file" using 2:3:(sprintf("{/Helvetica=%d %s}",\
20-$4, stringcolumn(4))) with labels
I have to make graph with gnuplot from some kind of input data. There is date, score and count for every entry. Graph should be with x axis representing date (I'll probably have question for that in the future too :/ ), y axis score and count should be represented by circles properly positioned in graph. The circles should have radius and color dependent on the count from input data.
Can anyone please set me in the right direction?
Thanks.
Edit:
Part of what I have:
set datafile separator ';'
set xdata time
set timefmt "%Y-%m-%d %H"
plot 'data' using 1:2:(some_function($3)) with circles
One line of data looks like this:
2014-02-21 19;0.5;5
However the circles seems like their radius depends on second column (0.5) instead of some_function(value_in_third_column), and I am not able to figure out where is the mistake.
Try the following:
plot 'datafile' with circles lc variable
(lc is short for linecolor) Type ? circles and ? palette at the gnuplot prompt to get started, and there are lots of examples online that should help you get an idea of how to do what you need.