Skip to content

New plotting methods for VertexOnlyMesh#5039

Merged
connorjward merged 24 commits intomainfrom
achanbour/plot-vom
Apr 22, 2026
Merged

New plotting methods for VertexOnlyMesh#5039
connorjward merged 24 commits intomainfrom
achanbour/plot-vom

Conversation

@achanbour
Copy link
Copy Markdown
Contributor

I have extended Firedrake's plotting routines to support the VertexOnlyMesh. In summary:

  • I added a new pointplot method that calls matplotlib.scatter for visualising the points of a VertexOnlyMesh,
  • I extended the existing quiver method to plot vector fields on a VertexOnlyMesh.

I've also added unit tests to make sure these changes work as expected. Unless anyone has anything to add or comment, I will edit Firedrake's documentation to include a demo of these new functionalities.

@achanbour achanbour requested a review from connorjward April 17, 2026 12:18
@achanbour achanbour self-assigned this Apr 17, 2026
@achanbour achanbour removed their assignment Apr 17, 2026
Copy link
Copy Markdown
Contributor

@connorjward connorjward left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

I'd add something small to the manual here.

Comment thread firedrake/pyplot/mpl.py Outdated
Comment thread firedrake/pyplot/mpl.py Outdated
Comment thread firedrake/pyplot/mpl.py Outdated
Comment thread firedrake/pyplot/mpl.py Outdated
Comment thread firedrake/pyplot/mpl.py
Comment thread firedrake/pyplot/mpl.py
@danshapero
Copy link
Copy Markdown
Contributor

This will be really useful, thanks! My one suggestion is that you call it scatter instead of pointplot. The other plotting routines have the same names as their counterparts in matplotlib so that people could guess the names of the function they wanted without having to consult the documentation.

@achanbour
Copy link
Copy Markdown
Contributor Author

This will be really useful, thanks! My one suggestion is that you call it scatter instead of pointplot. The other plotting routines have the same names as their counterparts in matplotlib so that people could guess the names of the function they wanted without having to consult the documentation.

This makes sense, thank you! I've now modified it to scatter.

Copy link
Copy Markdown
Contributor

@connorjward connorjward left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm basically happy now I think. Really nice.

Comment thread firedrake/pyplot/mpl.py Outdated
Comment thread firedrake/pyplot/mpl.py Outdated
Comment thread docs/source/visualisation.rst
Copy link
Copy Markdown
Contributor Author

@achanbour achanbour left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added serial run checks in all plotting methods.

Comment thread firedrake/pyplot/mpl.py Outdated
Comment thread firedrake/pyplot/mpl.py Outdated
Comment thread firedrake/pyplot/mpl.py Outdated
Comment thread firedrake/pyplot/mpl.py Outdated
Comment thread firedrake/pyplot/mpl.py Outdated
@JHopeCollins
Copy link
Copy Markdown
Member

This is great, thanks! Will it allow plotting points values when the parent mesh is 1D?

achanbour and others added 5 commits April 20, 2026 14:37
Co-authored-by: Leo Collins <leocollins511@gmail.com>
Co-authored-by: Leo Collins <leocollins511@gmail.com>
Co-authored-by: Leo Collins <leocollins511@gmail.com>
Co-authored-by: Leo Collins <leocollins511@gmail.com>
Co-authored-by: Leo Collins <leocollins511@gmail.com>
@achanbour
Copy link
Copy Markdown
Contributor Author

This is great, thanks! Will it allow plotting points values when the parent mesh is 1D?

Matplotlib's scatter assumes at least 2D so the code currently doesn't support 1D and raises an Exception.

if axes is None:
fig = plt.figure()
if gdim == 3:
axes = fig.add_subplot(111, projection="3d")
elif gdim == 2:
axes = fig.add_subplot(111)
else:
raise ValueError("Scatter is only supported for 2D and 3D meshes.")

@JHopeCollins
Copy link
Copy Markdown
Member

Matplotlib's scatter assumes at least 2D so the code currently doesn't support 1D and raises an Exception.

Of course, I'd forgotten there were separate calls for the 1D and 2D plotting

Comment thread firedrake/pyplot/mpl.py Outdated
@connorjward connorjward merged commit 6f8c2f4 into main Apr 22, 2026
5 of 7 checks passed
@connorjward connorjward deleted the achanbour/plot-vom branch April 22, 2026 11:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants