Versatility of the Plot
The code below in the Engee programming language is intended for plotting two functions and using the Plots package.
x = 0:0.1:10
y1 = sin.(x)
y2 = cos.(x)
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.
# 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
)
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.
plot!(x, y2,
label = "cos(x)",
linewidth = 2,
linestyle = :dash,
linecolor = :green
)
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.