'How to add multiple title to Python Plot using Matplotlib?
So I have a code which plots images and I use subplots to show multiple images on the plot. I need to print the varible values (var1, var2 and var3) on top of the image along with the image title.
The code is something like this:
plt.subplot(2,3,1);
plt.imshow(img[], cmap = 'grey');
plt.title('Image1');
plt.title(var1) # here we print the value stored in the var1 on top of the image next to title
plt.title(var2) # var2 is also printed on top of the image
plt.title(var3)
var1, var2, var3 are float values.
I tried using:
plt.title(var1, loc=('left'))
But this somehow overlaps over the image title.
The variable values needs to be printed above the image ( and the title - 'Image1' should also be present.
What is the best way to do this?
P.S. Matplotlib is to be used. Have a look at example image for reference.
Solution 1:[1]
The author of this code states in a comment:
It's technically not necessary, but it's good to be explicit.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Petr Hejda |
