Open JosephBARBIERDARNAL opened 22 hours ago
Hi! Thanks for using Positron.
I am not 100% sure if this is an issue with Positron or perhaps just an issue with usage. Could you try this and see if it meets your needs?
import matplotlib.pyplot as plt
fig = plt.figure()
ax1 = fig.add_subplot()
ax1.title.set_text('Title')
plt.show()
I ask because when i try to repro your original snippet outside Positron, I get the same result and with the snippet I provided, the title looks good.
A larger example: https://stackoverflow.com/questions/25239933/how-to-add-a-title-to-each-subplot
It's strange that this works when adding a title, but not when using text()
.
To be clearer about what I meant in the first place, ideally I should see on the plot window what I would see in a normal notebook or if I saved the plot as a png.
For example, this:
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
fig.text(
x=0.5, y=1, s='title', size=20
)
plt.tight_layout()
plt.savefig('positron.png', bbox_inches='tight')
plt.show()
gives me 2 differents results. positron.png
(or what I would have had in a notebook) looks like:
But in positron the plot window gives me:
Interestingly, this works perfectly:
import matplotlib.pyplot as plt
fig = plt.figure()
ax1 = fig.add_subplot()
ax1.set_title('title', y=1.3) # higher position
plt.show()
Thank you for the additional example! I do see what you mean when comparing to a notebook (with the savefig line commented out).
I will move this issue to triage for prioritization.
System details:
Positron and OS details:
Positron Version: 2024.08.0 (Universal) build 48 Code - OSS Version: 1.91.0 Commit: ed616b36655fb24d116108bdd833f1321704315b Date: 2024-08-19T04:26:51.868Z Electron: 29.4.0 Chromium: 122.0.6261.156 Node.js: 20.9.0 V8: 12.2.281.27-electron.0 OS: Darwin arm64 23.6.0
Interpreter details:
Python 3.12.5
Describe the issue:
For example, when I add an annotation to a matplotlib graph, if its position is outside certain values, it will not be displayed in the plot window.
The values in question appear to be outside 0 and 1 in the coordinates of the figure for the x and y axis.
Steps to reproduce the issue:
Expected or desired behavior:
Ideally, the plot window should zoom out (or similar) to ensure that it fits all the elements of the matplotlib figure.