OpenSite/Guides/Publish a plot

From BathAfrica Documentation
Revision as of 14:01, 29 October 2026 by BathAfrica (talk | contribs) (Add rewritten practical lesson with steps, code and expected results)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
OpenSite 0.0.1 · DevelopmentSource scope and availability


Draw a small arithmetic curve and publish it to an OpenSite plot tab.

Stable identifier
opensite.help.publish-a-plot

Prerequisites

Desktop GUI and Python, with Matplotlib in the matching scientific runtime. This example is not a structural-analysis result.

Steps

Create a figure

Use plt.subplots(), then label both axes and state units. The lesson plots length squared, not a solver response.

Publish the selected figure

Call opensite.plot.show(figure). Calling show() without an argument publishes open figures.

Read the plot tab

Plot views share the central workspace with scripts and document views. Switching workbench does not mean those tabs must close.

Zoom/pan navigate the published raster. Use the viewer’s Save/Copy actions when present; do not assume zoom recalculates Matplotlib axes or underlying engineering data.

Expected result

Four labelled points appear, with illustrative values 1, 4, 9 and 16 m².

Limitations

The current viewer publishes Agg-rendered images. Matplotlib must be present in the matching runtime; installing it into an unrelated system Python does not update OpenSite.

Complete example

import opensite
import matplotlib.pyplot as plt

lengths = [1.0, 2.0, 3.0, 4.0]
illustrative_values = [length * length for length in lengths]
figure, axes = plt.subplots()
axes.plot(lengths, illustrative_values, marker="o")
axes.set(xlabel="Input length (m)", ylabel="Illustrative value (m²)",
         title="Reading a published plot")
axes.grid(True)
opensite.plot.show(figure)
# This arithmetic demonstration is not a structural analysis result.