Engee documentation
Notebook

Versatility of the Plot

The code below in the Engee programming language is intended for plotting two functions and using the Plots package.

In [ ]:
x = 0:0.1:10
y1 = sin.(x)
y2 = cos.(x)
Out[0]:
101-element Vector{Float64}:
  1.0
  0.9950041652780258
  0.9800665778412416
  0.955336489125606
  0.9210609940028851
  0.8775825618903728
  0.8253356149096783
  0.7648421872844885
  0.6967067093471654
  0.6216099682706644
  0.5403023058681398
  0.4535961214255773
  0.3623577544766736
  ⋮
 -0.8654352092411123
 -0.9111302618846769
 -0.9477216021311119
 -0.9748436214041636
 -0.9922253254526034
 -0.9996930420352065
 -0.9971721561963784
 -0.984687855794127
 -0.9623648798313102
 -0.9304262721047533
 -0.8891911526253609
 -0.8390715290764524

The purpose of the demonstration is to show the maximum number of possible settings for the appearance of the graph. This example covers almost the entire range of visualization available in the package, starting from basic settings such as color and line thickness, ending with complex design parameters such as grid, markers, transparency of elements and border design.

Thanks to the use of a large number of parameters, the graph becomes expressive and informative, allowing you to emphasize important aspects of the data. This approach is ideal for exploring in detail the possibilities of batch plotting in Engee and achieving high-precision data visualization.

In [ ]:
# Plotting a graph with the maximum number of parameters
plot(x, y1, 
    label = "sin(x)",          # Caption for the legend
    title = "Graph of functions",  # Heading
    xlabel = "The X-axis",         # X-axis signature
    ylabel = "The Y axis",         # Y-axis signature
    legend = :topright,       # Legend position (:none, :left, :right, :top, :bottom, :best)
    linewidth = 2,            # Line thickness
    linestyle = :solid,       # Line style (:solid, :dash, :dot, :dashdot)
    linecolor = :blue,        # Line color (name, HEX, RGB)
    marker = :circle,         # Marker of points (:none, :circle, :square, :diamond, etc.)
    markersize = 5,           # Marker Size
    markercolor = :red,       # Marker Color
    markeralpha = 0.5,        # Transparency of the marker (0-1)
    markerstrokewidth = 1,    # Marker outline thickness
    markerstrokecolor = :black, # Marker outline color
    seriesalpha = 0.8,        # Transparency of the entire series (lines + markers)
    grid = true,              # Display the grid
    gridstyle = :dash,        # Grid Style
    gridalpha = 0.3,          # Transparency of the grid
    minorgrid = false,        # Enable an additional grid
    xlims = (0, 10),         # X-axis boundaries
    ylims = (-1.5, 1.5),     # Boundaries of the Y-axis
    xticks = 0:1:10,         # Divisions on the X-axis
    yticks = -1:0.5:1,       # Divisions on the Y axis
    framestyle = :box,       # Frame style (:box, :axes, :origin, :zerolines, :grid)
    background_color = :white,# Background color
    foreground_color = :black,# Foreground color (axes, text)
    size = (800, 400),       # Graph size in pixels (width, height)
    dpi = 100,               # Resolution (dots per inch)
    colorbar = false,        # Show the color scale (for heatmap, contour)
    clims = (0, 1),          # The boundaries of the color scale
    aspect_ratio = :auto,    # Axis ratio (:auto, :equal, number)
    inset = (1, bbox(0.5, 0.5, 0.3, 0.3)), # Insertion (subplot)
    subplot = 1,             # The number of the subgraph
    layout = @layout([a; b]),# Chart layout (used with `plot!`)
    palette = :viridis,      # Color palette (:viridis, :plasma, :magma, etc.)
    tickfontsize = 10,       # Font size of divisions
    guidefontsize = 12,      # Font size of axis signatures
    legendfontsize = 10,     # Legend font size
    titlefontsize = 14,      # Font size of the title
    widen = true,            # Automatically expand the boundaries of the axes
    reuse = false            # Reuse the current schedule
)
Out[0]:

Next, add the second line (cos(x)) to an existing schedule using the method plot!(). Here are its key features:

  • label="cos(x)": sets the line signature in the legend.
  • linewidth=2: Sets the line thickness to two units.
  • linestyle=:dash: makes the line dotted.
  • linecolor=:green: Turns the line green.

This approach is convenient for adding new data to the same graph without repeating the overall configuration.

In [ ]:
plot!(x, y2, 
    label = "cos(x)", 
    linewidth = 2, 
    linestyle = :dash, 
    linecolor = :green
)
Out[0]:

We can also use savefig() - This feature is useful for saving graph images for later use outside the development environment, for example, for inclusion in reports, presentations or publication of articles, for example by specifying a file name. savefig("my_plot.png")— we will create a graph in a PNG file with the name "my_plot.png" in the current working directory.

Conclusion

In this example, we have shown the maximum number of possible settings for the appearance of the Plots graph.