# DMelt:Plots/4 Showing 2D Shapes

# Simple 2D shapes

In addition to data, histograms, functions, jhplot.HPlot canvas can show arbitrary shapes (boxes, text, images, arrows) in the user ("USER") coordinates (i.e. given by the axis values) or in the absolute coordinates ("NDC"). You can mix data and shapes in arbitrary order.

The following shapes can be plotted:

- jhplot.shapes.Arrow - Arrow
- jhplot.shapes.Circle - Circle
- jhplot.shapes.Ellipse - Ellipse
- jhplot.shapes.Line - Line
- jhplot.shapes.Picture - Picture (in PNG or JPG formats)
- jhplot.shapes.Rectan - Rectangle
- jhplot.shapes.Text - Simple (not interactive) text

You should also remember that you can always draw shapes with data points. Here is an example how to draw an ellipse
with semi-major (longest radius) and semi-minor (shortest radius) radii:

Here is a simple code to do this:

You can convert it to Groovy or Java code using the same logic. Decrease the step size to obtain a smooth line.

Now let us construct rotated ellipse by some angle and overlay it with a 2D Ellipse using "2D" shape approach:

The code to generate this image is below:

No access to this part. DataMelt members can view this part after login to member area. |

Finally, one can generate random data points following the ellipse shape. We will use parametric description of the ellipse, rotate it and generate random numbers:

The Python code this image is below:

No access to this part. DataMelt members can view this part after login to member area. |

You can use the basic 2D primitives to draw shapes. Here is a simple example how to draw such shapes:

You can find a script that generates this image below. It shows how to add X-Y data, histograms a then draw simple 2D graphic primitives on the top:

No access to this part. DataMelt members can view this part after login to member area. |