Why will my y value not show up on my graph? [duplicate] - python

This question already has answers here:
How to plot a single point in matplotlib
(2 answers)
Closed yesterday.
I actually cannot seem to figure out why my y value will not show up on the graph. This is a much simpler graph than ones that I have done in the past, yet I seem to be struggling with this. What could be the reason that the y value won't show up?
When I change the value of y, the limits of the graph change accordingly but the value is still missing.

replace ax.plot(0, y) with replace ax.plot(0, y, marker='o')
Since (0, 2.5) is an infinitely small point, you need to give it a marker so it's visible.

Related

How can I change the size of the innermost circle in a plotly sunburst? [duplicate]

This question already has an answer here:
Is there a way to vary the thickness of a layer in sunburst diagram in plotly
(1 answer)
Closed last year.
I want to achieve this result but with plotly sunburst.
I can not find any parameter that controls the inner circle diameter in the documentation. It is any way to achieve that?
Unfortunately you can set only root_color. There is no attribute root_size. Just print help(go.sunburst.Root).

"Invert" Axis on Matplotlib / Seaborn

Good evening/morning/evening !
I am only a leisure programmer so I appologise if this question has been answered on here before under a different title, I didn't know what to search for.
If you see below I have plotted two graphs, one a 2d and the other a 3d using matplotlib.
My issue is that I wish for (0,0) to be in the bottom left corner and a step to the right to be +1 and a step upwards to be -1. Instead of having x increase and y decrease. If it is needed I will post the entire code for these plots but they have both been done conventionally with seaborn.heatmap(z) and ax.plot_surface(x,y,z).
Also I am using the following line I found on here: ax = fig.add_subplot(2, 1, 1)
Could someone please explain the parameters of this function to me I am struggling to understand what they mean.
Any help is greatly appreciated and again I apologise if this has been posted before :)
In matplotlib:
If you want to invert the x-axis:
ax.invert_xaxis()
If you want to invert the y-axis:
ax.invert_yaxis()
If you want to invert the z-axis:
ax.invert_zaxis()
I'm pretty sure that these functions will work in seaborn as well, since it is built on top of matplotlib!

Coloring Individual Points of a Scatter Plot in Python3 [duplicate]

This question already has answers here:
Scatter plot and Color mapping in Python
(4 answers)
Closed 3 years ago.
I am currently working on a project that deals with a scatter plot, made using matplotlib and numpy,
I was wondering whether I could assign color to each point based on their (x,y) coordinates, assume that I have a function that maps (x,y) to (r,g,b). There are a lot of points (~250,000).
Is there any possible way to achieve this?
Matplotlib's scatter plot supports this via the color parameter, check this example. You have to prepare your colors beforehand and pass it to the color. As mentioned, color can be a sequence.
Another way, maybe slightly faster, would be to use seaborn's scatter plot.

Remove dashes from grid [duplicate]

This question already has an answer here:
Remove the x-axis ticks while keeping the grids (matplotlib) [duplicate]
(1 answer)
Closed 5 years ago.
If I run this code
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(111)
ax.xaxis.set_tick_params(length=0,labelsize=0)
ax.grid(True)
I get the following:
The xaxis ticks and labels don't show (as expected), but some dashes appear on the bottom of the plot (the first three of which I have circled in red).
How can I remove them? I have looked at the documentation for grids, but can't find anything.
An answer which teaches me how I could have figured out how to do this by looking at the documentation would be particularly useful.
What you see are the ticklabels, which have size 0. Even zero sized ticks appear as a single dot because of antigraining.
You probably want to set the label off completely
ax.xaxis.set_tick_params(length=0,labelbottom=False)
You find out about this by looking at the available arguments in the documentation.

Matplotlib figure not working [duplicate]

This question already has answers here:
How do I change the size of figures drawn with Matplotlib?
(14 answers)
Closed 5 years ago.
I have all of my graphs working, so now I am trying to scale my plots down to a relatively small size (3x3in). I added the figure command and the graph goes blank. Right size, just blank. I'm obviously missing something basic but it's beating me. When I comment it out, it shows fine ( if a bit big). When I include it, it blanks the image.
What am I doing incorrectly ?
plt.setp(line[lindex], linewidth=1.0)
plt.setp(line[lindex+1], linewidth=2.0)
plt.xlabel("Months")
plt.ylabel("Score")
plt.title(CurrAppName + "- by month")
plt.legend()
# plt.figure(figsize=(3,3))
plt.show()
If this is your whole code, just put the plt.figure(figsize=(3, 3)) as the first line. Here, declaring plt.figure(...) in the end means you are creating a whole new plot after you've drawn into the last one. You don't want that.

Categories