This question already has an answer here:
Getting text to display in front of subplot images
(1 answer)
Closed 5 years ago.
I have created some subplots using matplotlib librairies (pyplot and gridspec). I am trying to put some text in front of the graphs, but sometimes they are located below, in the background so I can't see them.
I don't know if I should used plt.text or annonate or rather use methods of sublplots?
If you change the command window to white you should be able to see the text. If you are using the command %matplotlib inline, together with a black command window, the text will not always be visible.
Related
This question already has answers here:
Matplotlib: How to plot images instead of points?
(2 answers)
How to insert a UTF-8 character onto an image
(1 answer)
Placing Custom Images in a Plot Window--as custom data markers or to annotate those markers
(5 answers)
How to make a tkinter canvas background transparent?
(2 answers)
Closed last month.
I wanted to make a chess game in python, but then I saw that you can do a lot of amazing things in matplotlib in terms of designing. I know that this is probably not the best way of doing this but I want to try this. Here is my main question.
How to scale and position images in matplotlib and tell me a bit more about it if possible?
This is what I have at this point:
import matplotlib.pyplot as plt
im = plt.imread('C:\\...\\bb.png')
imgplot = plt.imshow(im)
plt.show()
This just displays the image, I cant realy scale it nor position it.
I also found something like this, it displays the image in the right corner but I can't change anything or it just disappears or nothing happens... In short only misery.
newax = fig.add_axes([0.6,0.8,0.2,0.2], anchor='NE', zorder=1,)
newax.imshow(im)
newax.axis('off') #If I remove this there is a frame
Please help me out.
This question already has answers here:
Typewriter Effect Pygame
(2 answers)
Python Pygame Font x coordinate
(2 answers)
Paragraph input in pygame
(1 answer)
Closed 10 months ago.
I'm working on creating a dialogue box in Pygame. The problem I'm stuck in at the moment is being able to write the text in the box one letter at a time and the text must also be on multiple lines.
To write the text one letter at a time, I adapted the code found in this answer from sloth.
While for the multiline part of the text I found this code by Ted Klein Bergman.
What I would like to do is to merge the second to make the text, in addition to appearing one letter at a time, to be on several lines, but I have no ideas on how to change the first with the second in order to be able to obtain the result that i am looking for. Do you have any ideas, or can you help me solve the question? Thanks to anyone.
This question already has answers here:
How do I change the figure size with subplots?
(6 answers)
Matplotlib different size subplots
(6 answers)
Closed 2 years ago.
I would like to change the size of a graph (with multiple plots) in python to make it larger. using 'plt.figure(figsize=(6,3))' for example makes a new graph of a different size but its empty with just the axes, the actual plots do not show. can someone help me understand where i am going wrong? i have attached an image of my code in this question. thank you in advance enter image description here
Always write the plt.figure(figsize=(x,y)) before the line of code that will create the plot and end it by plt.show()
This question already has answers here:
How to add hovering annotations to a plot
(12 answers)
Closed 3 years ago.
How can I plot a figure in Python like MATLAB with the following features?:
1) I can zoom in and zoom out.
2) I can modify the range for x and y on the figure
3) I can click on the figure to see actual numbers related to each data point
Another question, how can we specify with wath resolution the matplotlib saves the figure?
To the best of my knowledge, MATPLOTLIB does not have that. Anything else?
I would recommend looking at plotly.
Plotly allows you to make graphs that can be
1) zoomed in on
2) change the x and y-axis numbers by dragging on the axes (but cant switch from say, log scale to linear scale as easily -- something like this would require an interaction feature)
3) Plotly allows you to display info on cursor-hover
For an example of a plotly plot in use, see this washington post page.
This question already has answers here:
Removing white space around a saved image
(15 answers)
Closed 4 years ago.
I want to have a matplotlib figure without ANY padding. Currently I do this manually via the IPython (Spyder3) interactive window and its configure subplots window. As shown in this figure.
I need to automate this process and decided to have a look at the Tight layout options.
fig.set_tight_layout(True)
fig.tight_layout(rect=[0, 0, 1, 1])
This does not result in the intended result as some margins do still remain. As shown here.
How do I force figures to have no padding at all. I expect the setting to exist as I'm able to change it in the GUI of IPython.
The GUI option you're using can be coded with the plt.subplots_adjust command. Something like plt.subplots_adjust(left=0, right=1, top=1, bottom=0) should achieve what you want