english translation started
This commit is contained in:
@@ -10,41 +10,41 @@ using InteractiveUtils
|
||||
```
|
||||
|
||||
|
||||
# Plots und Datenvisualisierung in Julia: _Plots.jl_
|
||||
# Plots and Data Visualization in Julia: _Plots.jl_
|
||||
|
||||
Es gibt zahlreiche Grafikpakete für Julia. Zwei oft genutzte sind [Makie.jl](https://docs.makie.org/stable/) und
|
||||
[Plots.jl](https://docs.juliaplots.org/latest/). Bevor wir diese genauer vorstellen, seien noch einige andere Pakete aufgelistet.
|
||||
There are numerous graphics packages for Julia. Two frequently used ones are [Makie.jl](https://docs.makie.org/stable/) and
|
||||
[Plots.jl](https://docs.juliaplots.org/latest/). Before presenting these in more detail, some other packages are listed.
|
||||
|
||||
## Kurze Übersicht: einige Grafikpakete
|
||||
## Brief Overview: Some Graphics Packages
|
||||
|
||||
| Paket/Doku | Tutorial | Beispiele | Bemerkungen |
|
||||
| Package/Documentation | Tutorial | Examples | Remarks |
|
||||
|:----|:--|:--|:--------|
|
||||
|[Plots.jl](https://docs.juliaplots.org/latest/) | [Tutorial](https://docs.juliaplots.org/latest/tutorial/) | [Galerie](https://goropikari.github.io/PlotsGallery.jl/) | konzipiert als einheitliches Interface zu verschiedenen _backends_ (Grafikbibliotheken) |
|
||||
| [Makie.jl](https://docs.makie.org/stable/) | [Basic tutorial](https://docs.makie.org/v0.21/tutorials/basic-tutorial) | [Beautiful Makie](https://beautiful.makie.org/) | "data visualization ecosystem for Julia", Backends: Cairo (Vektorgrafik), OpenGL, WebGL |
|
||||
|[PlotlyJS.jl](http://juliaplots.org/PlotlyJS.jl/stable/) | [Getting started](https://plotly.com/julia/getting-started/)| [Examples](https://plotly.com/julia/plotly-fundamentals/)| Interface zur [Plotly](https://plotly.com/graphing-libraries/) Javascript-Grafikbibliothek |
|
||||
| [Gadfly.jl](https://gadflyjl.org/stable/)| [Tutorial](https://gadflyjl.org/stable/tutorial/) | [Galerie](https://github.com/GiovineItalia/Gadfly.jl?tab=readme-ov-file#gallery)| "a plotting and data visualization system written in Julia, influenced by R's [ggplot2](https://ggplot2.tidyverse.org/)" |
|
||||
| [Bokeh.jl](https://cjdoris.github.io/Bokeh.jl/stable/) | | [Galerie](https://cjdoris.github.io/Bokeh.jl/stable/gallery/)| Julia-Frontend für [Bokeh](https://bokeh.org/) |
|
||||
|[VegaLite.jl](https://www.queryverse.org/VegaLite.jl/stable/) | [Tutorial](https://www.queryverse.org/VegaLite.jl/stable/gettingstarted/tutorial/)| [Examples](https://www.queryverse.org/VegaLite.jl/stable/examples/examples_barcharts/)| Julia-Frontend für [Vega-Lite](https://vega.github.io/vega-lite/)|
|
||||
| [Luxor.jl](http://juliagraphics.github.io/Luxor.jl/stable/) |[Tutorial](https://juliagraphics.github.io/Luxor.jl/stable/tutorial/helloworld/)|[Examples](https://juliagraphics.github.io/Luxor.jl/stable/example/moreexamples/)| Allgemeine Vektorgrafik/Illustrationen |
|
||||
| [Javis.jl](https://juliaanimators.github.io/Javis.jl/stable/) |[Tutorials](https://juliaanimators.github.io/Javis.jl/stable/tutorials/)| [Examples](https://juliaanimators.github.io/Javis.jl/stable/examples/)| *Animierte* Vektorgrafik
|
||||
|[Plots.jl](https://docs.juliaplots.org/latest/) | [Tutorial](https://docs.juliaplots.org/latest/tutorial/) | [Gallery](https://goropikari.github.io/PlotsGallery.jl/) | designed as a unified interface to various _backends_ (graphics libraries) |
|
||||
| [Makie.jl](https://docs.makie.org/stable/) | [Basic tutorial](https://docs.makie.org/v0.21/tutorials/basic-tutorial) | [Beautiful Makie](https://beautiful.makie.org/) | "data visualization ecosystem for Julia", backends: Cairo (vector graphics), OpenGL, WebGL |
|
||||
|[PlotlyJS.jl](http://juliaplots.org/PlotlyJS.jl/stable/) | [Getting started](https://plotly.com/julia/getting-started/)| [Examples](https://plotly.com/julia/plotly-fundamentals/)| Interface to the [Plotly](https://plotly.com/graphing-libraries/) JavaScript graphics library |
|
||||
| [Gadfly.jl](https://gadflyjl.org/stable/)| [Tutorial](https://gadflyjl.org/stable/tutorial/) | [Gallery](https://github.com/GiovineItalia/Gadfly.jl?tab=readme-ov-file#gallery)| "a plotting and data visualization system written in Julia, influenced by R's [ggplot2](https://ggplot2.tidyverse.org/)" |
|
||||
| [Bokeh.jl](https://cjdoris.github.io/Bokeh.jl/stable/) | | [Gallery](https://cjdoris.github.io/Bokeh.jl/stable/gallery/)| Julia frontend for [Bokeh](https://bokeh.org/) |
|
||||
|[VegaLite.jl](https://www.queryverse.org/VegaLite.jl/stable/) | [Tutorial](https://www.queryverse.org/VegaLite.jl/stable/gettingstarted/tutorial/)| [Examples](https://www.queryverse.org/VegaLite.jl/stable/examples/examples_barcharts/)| Julia frontend for [Vega-Lite](https://vega.github.io/vega-lite/)|
|
||||
| [Luxor.jl](http://juliagraphics.github.io/Luxor.jl/stable/) |[Tutorial](https://juliagraphics.github.io/Luxor.jl/stable/tutorial/helloworld/)|[Examples](https://juliagraphics.github.io/Luxor.jl/stable/example/moreexamples/)| General vector graphics/illustrations |
|
||||
| [Javis.jl](https://juliaanimators.github.io/Javis.jl/stable/) |[Tutorials](https://juliaanimators.github.io/Javis.jl/stable/tutorials/)| [Examples](https://juliaanimators.github.io/Javis.jl/stable/examples/)| *Animated* vector graphics
|
||||
| [TidierPlots.jl](https://github.com/TidierOrg/TidierPlots.jl)| [Reference](https://tidierorg.github.io/TidierPlots.jl/latest/) || "is a 100% Julia implementation of the R package ggplot2 powered by Makie.jl"|
|
||||
|[PythonPlot.jl](https://github.com/JuliaPy/PythonPlot.jl)| |[Examples (in Python)](https://matplotlib.org/stable/gallery/index.html)| Interface zu Matplotlib (Python), 1:1-Übertragung der Python-API, deswegen s. [Matplotlib-Dokumentation](https://matplotlib.org/stable/api/pyplot_summary.html)
|
||||
|[PythonPlot.jl](https://github.com/JuliaPy/PythonPlot.jl)| |[Examples (in Python)](https://matplotlib.org/stable/gallery/index.html)| Interface to Matplotlib (Python), 1:1 transfer of the Python API, therefore see [Matplotlib documentation](https://matplotlib.org/stable/api/pyplot_summary.html)
|
||||
|
||||
: {.striped .hover}
|
||||
{: .striped .hover}
|
||||
|
||||
<!--
|
||||
| [PyPlot.jl](https://github.com/JuliaPy/PyPlot.jl) | | [Examples](https://gist.github.com/gizmaa/7214002)| Interface zu Matplotlib (Python), 1:1-Übertragung der Python-API, deswegen s. [Matplotlib-Dokumentation](https://matplotlib.org/stable/) |
|
||||
| [PyPlot.jl](https://github.com/JuliaPy/PyPlot.jl) | | [Examples](https://gist.github.com/gizmaa/7214002)| Interface to Matplotlib (Python), 1:1 transfer of the Python API, therefore see [Matplotlib documentation](https://matplotlib.org/stable/) |
|
||||
-->
|
||||
|
||||
## Plots.jl
|
||||
|
||||
### Einfache Plots
|
||||
### Simple Plots
|
||||
|
||||
Die `plot()`-Funktion erwartet im einfachsten Fall:
|
||||
The `plot()` function expects, in the simplest case:
|
||||
|
||||
- als erstes Argument einen Vektor von $x$-Werten der Länge $n$ und
|
||||
- als zweites Argument einen gleichlangen Vektor mit den dazugehörigen $y$-Werten.
|
||||
- Das zweite Argument kann auch eine $n\times m$-Matrix sein. Dann wird jeder Spaltenvektor als eigener Graph (in der Docu `series` genannt) angesehen und es werden $m$ Kurven geplottet:
|
||||
- as the first argument a vector of $x$-values of length $n$ and
|
||||
- as the second argument a vector of the same length with the corresponding $y$-values.
|
||||
- The second argument can also be an $n\times m$-matrix. Then each column vector is regarded as a separate graph (called `series` in the documentation) and $m$ curves are plotted:
|
||||
|
||||
|
||||
```{julia}
|
||||
@@ -57,16 +57,16 @@ cx = @. cos(2x^(1/2))
|
||||
plot(x, [sx cx])
|
||||
```
|
||||
|
||||
- Die Funktionen des _Plots.jl_-Paketes wie `plot(), scatter(), contour(), heatmap(), histogram(), bar(),...` usw. starten alle einen neuen Plot.
|
||||
- Die Versionen `plot!(), scatter!(), contour!(), heatmap!(), histogram!(), bar!(),...` erweitern einen existierenden Plot:
|
||||
- The functions of the _Plots.jl_ package such as `plot(), scatter(), contour(), heatmap(), histogram(), bar(),...` etc. all start a new plot.
|
||||
- The versions `plot!(), scatter!(), contour!(), heatmap!(), histogram!(), bar!(),...` extend an existing plot:
|
||||
|
||||
```{julia}
|
||||
plot(x, sx) # plot only sin(x)
|
||||
plot!(x, cx) # add second graph
|
||||
plot!(x, sqrt.(x)) # add a thirth one
|
||||
plot!(x, sqrt.(x)) # add a third one
|
||||
```
|
||||
|
||||
Plots sind Objekte, die zugewiesen werden können. Dann kann man sie später weiterverwenden, kopieren und insbesondere mit den `!`-Funktionen erweitern:
|
||||
Plots are objects that can be assigned. Then they can be used later, copied, and in particular extended with the `!` functions:
|
||||
|
||||
```{julia}
|
||||
plot1 = plot(x, [sx cx])
|
||||
@@ -74,7 +74,7 @@ plot1a = deepcopy(plot1) # plot objects are quite deep structures
|
||||
scatter!(plot1, x, sx) # add scatter plot, i.e. unconnected data points
|
||||
```
|
||||
|
||||
Die kopierte Version `plot1a` ist durch die `scatter!`-Anweisung nicht modifiziert worden und kann unabhängig weiterverwendet werden:
|
||||
The copied version `plot1a` has not been modified by the `scatter!` statement and can be used independently:
|
||||
|
||||
```{julia}
|
||||
plot!(plot1a, x, 2 .* sx)
|
||||
@@ -82,7 +82,7 @@ plot!(plot1a, x, 2 .* sx)
|
||||
|
||||
|
||||
|
||||
Plot-Objekte kann man als Grafikdateien (PDF, SVG, PNG,...) abspeichern:
|
||||
Plot objects can be saved as graphics files (PDF, SVG, PNG,...):
|
||||
|
||||
|
||||
```{julia}
|
||||
@@ -94,13 +94,13 @@ savefig(plot1, "plot.png")
|
||||
;ls -l plot.png
|
||||
```
|
||||
|
||||
Plot-Objekte können auch als Teilplot in andere Plots eingefügt werden, siehe Abschnitt @sec-subplot.
|
||||
Plot objects can also be inserted as subplots into other plots, see section @sec-subplot.
|
||||
|
||||
|
||||
|
||||
### Funktionsplots
|
||||
### Function Plots
|
||||
|
||||
Man kann `plot()` auch eine Funktion und einen Vektor mit $x$-Werten übergeben:
|
||||
`plot()` can also be passed a function and a vector of $x$-values:
|
||||
|
||||
```{julia}
|
||||
# https://mzrg.com/math/graphs.shtml
|
||||
@@ -109,9 +109,9 @@ f(x) = abs(sin(x^x)/2^((x^x-π/2)/π))
|
||||
|
||||
plot(f, 0:0.01:3)
|
||||
```
|
||||
|
||||
|
||||
|
||||
Die parametrische Form $x = x(t),\ y = y(t)$ kann durch die Übergabe von zwei Funktionen und einen Vektor von $t$-Werten an `plot()` gezeichnet werden.
|
||||
The parametric form $x = x(t),\ y = y(t)$ can be drawn by passing two functions and a vector of $t$-values to `plot()`.
|
||||
|
||||
```{julia}
|
||||
# https://en.wikipedia.org/wiki/Butterfly_curve_(transcendental)
|
||||
@@ -123,16 +123,16 @@ plot(xt, yt, 0:0.01:12π)
|
||||
```
|
||||
|
||||
|
||||
### Plot-Themen
|
||||
### Plot Themes
|
||||
|
||||
> "PlotThemes is a package to spice up the plots made with Plots.jl."\
|
||||
Hier geht es zur illustrierten [Liste der Themen](https://docs.juliaplots.org/stable/generated/plotthemes/)
|
||||
Here is the illustrated [list of themes](https://docs.juliaplots.org/stable/generated/plotthemes/)
|
||||
|
||||
oder:
|
||||
or:
|
||||
```{julia}
|
||||
using PlotThemes
|
||||
|
||||
# Liste der Themen
|
||||
# list of themes
|
||||
keys(PlotThemes._themes)
|
||||
```
|
||||
|
||||
@@ -149,48 +149,48 @@ plot(x, [sx cx 1 ./ (1 .+ x)])
|
||||
```
|
||||
|
||||
|
||||
### Plot-Attribute
|
||||
### Plot Attributes
|
||||
|
||||
Die Funktionen des `Plots.jl`-Paketes haben eine große Anzahl von Optionen.
|
||||
`Plots.jl` teilt die Attribute in 4 Gruppen ein:
|
||||
The functions of the `Plots.jl` package have a large number of options.
|
||||
`Plots.jl` divides the attributes into 4 groups:
|
||||
|
||||
::::{.cell}
|
||||
```{julia}
|
||||
#| output: asis
|
||||
plotattr(:Plot) # Attribute für den Gesamtplot
|
||||
plotattr(:Plot) # attributes for the overall plot
|
||||
```
|
||||
::::
|
||||
|
||||
::::{.cell}
|
||||
```{julia}
|
||||
#| output: asis
|
||||
plotattr(:Subplot) # Attribute für einen Teilplot
|
||||
plotattr(:Subplot) # attributes for a subplot
|
||||
```
|
||||
::::
|
||||
|
||||
::::{.cell}
|
||||
```{julia}
|
||||
#| output: asis
|
||||
plotattr(:Axis) # Attribute für eine Achse
|
||||
plotattr(:Axis) # attributes for an axis
|
||||
```
|
||||
::::
|
||||
|
||||
::::{.cell}
|
||||
```{julia}
|
||||
#| output: asis
|
||||
plotattr(:Series) # Attribute für eine Serie, also zB ein Linienzug im Plot
|
||||
plotattr(:Series) # attributes for a series, e.g., a line in the plot
|
||||
```
|
||||
::::
|
||||
|
||||
Man kann auch nachfragen, was die einzelnen Attribute bedeuten und welche Werte zulässig sind:
|
||||
One can also ask what the individual attributes mean and which values are allowed:
|
||||
```{julia}
|
||||
plotattr("linestyle")
|
||||
```
|
||||
|
||||
|
||||
Ein Beispiel:
|
||||
An example:
|
||||
```{julia}
|
||||
theme(:default) # zurück zum Standardthema
|
||||
theme(:default) # return to default theme
|
||||
|
||||
x = 0:0.05:1
|
||||
y = sin.(2π*x)
|
||||
@@ -200,9 +200,9 @@ plot(x, y, seriestype = :sticks, linewidth = 4, seriescolor = "#00b300",
|
||||
)
|
||||
```
|
||||
|
||||
Viele Angaben können auch sehr weit abgekürzt werden, siehe z.B. die Angabe `Aliases:` in der obigen Ausgabe des Kommandos `plotattr("linestyle")`.
|
||||
Many specifications can also be abbreviated significantly, see e.g. the `Aliases:` in the above output of the command `plotattr("linestyle")`.
|
||||
|
||||
Das folgende `plot()`-Kommando is äquivalent zum vorherigen:
|
||||
The following `plot()` command is equivalent to the previous one:
|
||||
|
||||
```{julia}
|
||||
#| eval: false
|
||||
@@ -210,61 +210,61 @@ plot(x, y, t = :sticks, w = 4, c = "#00b300", m = (:circle, 8, :green ))
|
||||
```
|
||||
|
||||
|
||||
### Weitere Extras
|
||||
### Additional Extras
|
||||
|
||||
```{julia}
|
||||
using Plots # Wiederholung schadet nicht
|
||||
using Plots.PlotMeasures # für Maßangaben in mm, cm,...
|
||||
using LaTeXStrings # für LaTeX-Konstrukte in Plot-Beschriftungen
|
||||
using PlotThemes # vorgefertigte Themen
|
||||
using Plots # repetition does not hurt
|
||||
using Plots.PlotMeasures # for measurements in mm, cm,...
|
||||
using LaTeXStrings # for LaTeX constructs in plot labels
|
||||
using PlotThemes # predefined themes
|
||||
```
|
||||
|
||||
Das Paket `LaTeXStrings.jl` stellt einen String-Konstruktor `L"..."` zur Verfügung. Diese Strings können LaTeX-Konstrukte, insbesondere Formeln, enthalten. Wenn der String keine expliziten Dollarzeichen enthält, wird er automatisch im LaTeX-Math-Modus interpretiert.
|
||||
The `LaTeXStrings.jl` package provides a string constructor `L"..."`. These strings can contain LaTeX constructs, especially formulas. If the string does not contain explicit dollar signs, it is automatically interpreted in LaTeX math mode.
|
||||
|
||||
```{julia}
|
||||
xs = range(0, 2π, length = 100)
|
||||
|
||||
data = [sin.(xs) cos.(xs) 2sin.(xs) (x->sin(x^2)).(xs)] # 4 Funktionen
|
||||
data = [sin.(xs) cos.(xs) 2sin.(xs) (x->sin(x^2)).(xs)] # 4 functions
|
||||
|
||||
theme(:ggplot2)
|
||||
|
||||
plot10 = plot(xs, data,
|
||||
fontfamily="Computer Modern",
|
||||
|
||||
# LaTeX-String L"..."
|
||||
# LaTeX string L"..."
|
||||
title = L"Winkelfunktionen $\sin(\alpha), \cos(\alpha), 2\sin(\alpha), \sin(\alpha^2)$",
|
||||
xlabel = L"Winkel $\alpha$",
|
||||
ylabel = "Funktionswert",
|
||||
|
||||
# 1x4-Matrizen mit Farben, Marker,... für die 4 'Series'
|
||||
# 1x4-matrices with colors, markers,... for the 4 'series'
|
||||
color=[:black :green RGB(0.3, 0.8, 0.2) :blue ],
|
||||
markers = [:rect :circle :utriangle :diamond],
|
||||
markersize = [2 1 0 4],
|
||||
linewidth = [1 3 1 2],
|
||||
linestyle = [:solid :dash :dot :solid ],
|
||||
|
||||
# Achsen
|
||||
# axes
|
||||
xlim = (0, 6.6),
|
||||
ylim = (-2, 2.3),
|
||||
yticks = -2:.4:2.3, # mit Schrittweite
|
||||
yticks = -2:.4:2.3, # with step size
|
||||
|
||||
# Legende
|
||||
# legend
|
||||
legend = :bottomleft,
|
||||
label = [ L"\sin(\alpha)" L"\cos(\alpha)" L"2\sin(\alpha)" L"\sin(\alpha^2)"],
|
||||
|
||||
top_margin = 5mm, # hier wird Plots.PlotMeasures gebraucht
|
||||
top_margin = 5mm, # here Plots.PlotMeasures is needed
|
||||
)
|
||||
|
||||
# Zusatztext: annotate!(x-pos, y-pos, text("...", font, fontsize))
|
||||
# additional text: annotate!(x-pos, y-pos, text("...", font, fontsize))
|
||||
|
||||
annotate!(plot10, 4.1, 1.8, text("nicht schön, aber viel","Computer Modern", 10) )
|
||||
```
|
||||
|
||||
### Andere Plot-Funktionen
|
||||
### Other Plot Functions
|
||||
|
||||
Bisher haben wir vor allem Linien geplottet. Es gibt noch viele andere Typen wie _scatter plot, contour, heatmap, histogram, stick,..._
|
||||
So far, we have plotted mainly lines. There are many other types such as _scatter plot, contour, heatmap, histogram, stick,..._
|
||||
|
||||
Dies kann man mit dem `seriestype`-Attribut steuern:
|
||||
This can be controlled with the `seriestype` attribute:
|
||||
|
||||
```{julia}
|
||||
theme(:default)
|
||||
@@ -273,7 +273,7 @@ x = range(0, 2π; length = 50)
|
||||
plot(x, sin.(x), seriestype=:scatter)
|
||||
```
|
||||
|
||||
oder indem man die spezielle Funktion benutzt, die so heißt wie der `seriestype`:
|
||||
or by using the specific function named after the `seriestype`:
|
||||
```{julia}
|
||||
x = range(0, 2π; length = 50)
|
||||
scatter(x, sin.(x))
|
||||
@@ -281,9 +281,9 @@ scatter(x, sin.(x))
|
||||
|
||||
|
||||
|
||||
### Subplots und Layout {#sec-subplot}
|
||||
### Subplots and Layout {#sec-subplot}
|
||||
|
||||
Mehrere Plots können zu einer Abbildung zusammengefasst werden. Die Anordnung bestimmt der `layout`-Parameter. Dabei bedeutet `layout=(m,n)`, dass die Plots in einem $m\times n$-Schema angeordnet werden:
|
||||
Multiple plots can be combined into one figure. The arrangement is determined by the `layout` parameter. `layout=(m,n)` means that the plots are arranged in an $m\times n$ scheme:
|
||||
|
||||
```{julia}
|
||||
x = range(0, 2π; length = 100)
|
||||
@@ -300,7 +300,7 @@ plot(plots..., layout=(4,1), legend=false, title=["sin" "cos" "tan" "sinc"])
|
||||
```
|
||||
|
||||
|
||||
Man kann Layouts auch schachteln und mit dem `@layout`-Macro explizite Breiten/Höhenanteile vorgeben:
|
||||
Layouts can also be nested and explicit width/height proportions can be specified using the `@layout` macro:
|
||||
|
||||
|
||||
```{julia}
|
||||
@@ -317,27 +317,27 @@ plot(plots..., layout=mylayout, legend=false, title=["sin" "cos" "tan" "sinc"])
|
||||
|
||||
### Backends
|
||||
|
||||
`Plots.jl` ist konzipiert als ein einheitliches Interface zu verschiedenen _backends_ (Grafik-Engines). Man kann zu einem anderen Backend wechseln und dieselben Plot-Kommandos und -Attribute verwenden.
|
||||
`Plots.jl` is designed as a unified interface to various _backends_ (graphics engines). One can switch to another backend and use the same plot commands and attributes.
|
||||
|
||||
Allerdings unterstützen nicht alle _backends_ alle Plot-Typen und -Attribute. Einen Überblick gibt es [hier](https://docs.juliaplots.org/stable/generated/supported/).
|
||||
However, not all _backends_ support all plot types and attributes. An overview is available [here](https://docs.juliaplots.org/stable/generated/supported/).
|
||||
|
||||
Bisher wurde das Standard-Backend verwendet. Es heißt [GR](https://gr-framework.org/about.html) und ist eine am Forschungszentrum Jülich entwickelte und hauptsächlich in C geschriebene Grafik-Engine.
|
||||
So far, the default backend has been used. It is called [GR](https://gr-framework.org/about.html) and is a graphics engine developed at the Jülich Research Center and written primarily in C.
|
||||
|
||||
|
||||
```{julia}
|
||||
using Plots
|
||||
backend() # Anzeige des gewählten backends, GR ist der default
|
||||
backend() # display the selected backend, GR is the default
|
||||
```
|
||||
|
||||
|
||||
Nochmal ein Beispiel
|
||||
Another example
|
||||
```{julia}
|
||||
x = 1:30
|
||||
y = rand(30)
|
||||
plot(x, y, linecolor =:green, bg_inside =:lightblue1, line =:solid, label = "Wasserstand")
|
||||
```
|
||||
|
||||
und hier derselbe Plot mit dem `PlotlyJS`-Backend.
|
||||
and here the same plot with the `PlotlyJS` backend.
|
||||
|
||||
|
||||
```{julia}
|
||||
@@ -345,22 +345,22 @@ plotlyjs() # change plots backend
|
||||
plot(x, y, linecolor =:green, bg_inside =:lightblue1, line =:solid, label = "Wasserstand")
|
||||
```
|
||||
|
||||
Dieses Backend ermöglich mit Hilfe von Javascript eine gewisse Interaktivität. Wenn man die Maus in das Bild bewegt, kann man mit der Maus zoomen, verschieben und 3D-Plots auch drehen.
|
||||
This backend enables a certain interactivity using JavaScript. When moving the mouse into the image, one can zoom and pan with the mouse, and 3D plots can also be rotated.
|
||||
|
||||
|
||||
```{julia}
|
||||
gr() # zurück zu GR als backend
|
||||
gr() # return to GR as backend
|
||||
```
|
||||
|
||||
|
||||
|
||||
### 3D Plots
|
||||
|
||||
Die Funktionen `surface()` und `contour()` ermöglichen den Plot einer Funktion $f(x,y)$. Als Argumente werden benötigt:
|
||||
The functions `surface()` and `contour()` allow plotting of a function $f(x,y)$. The required arguments are:
|
||||
|
||||
- eine Menge (Vektor) $X$ von $x$-Werten,
|
||||
- eine Menge (Vektor) $Y$ von $y$-Werten und
|
||||
- eine Funktion von zwei Variablen, die dann auf $X \times Y$ ausgewertet und geplottet wird.
|
||||
- a set (vector) $X$ of $x$-values,
|
||||
- a set (vector) $Y$ of $y$-values and
|
||||
- a function of two variables that is then evaluated on $X \times Y$ and plotted.
|
||||
|
||||
```{julia}
|
||||
f(x,y) = (1 - x/2 + x^5 + y^3) * exp(-x^2 - y^2)
|
||||
@@ -372,8 +372,8 @@ surface( -3:0.02:3, -3:0.02:3, f)
|
||||
contour( -3:0.02:3, -3:0.02:3, f, fill=true, colormap=:summer, levels=20, contour_labels=false)
|
||||
```
|
||||
|
||||
Kurven (oder auch einfach Punktmengen) in drei Dimensionen lassen sich plotten, indem man `plot()` mit 3 Vektoren
|
||||
aufruft, die jeweils die $x$, $y$ und $z$-Koordinaten der Datenpunkte enthalten.
|
||||
Curves (or simply point sets) in three dimensions can be plotted by calling `plot()` with 3 vectors
|
||||
containing the $x$, $y$ and $z$-coordinates of the data points, respectively.
|
||||
|
||||
```{julia}
|
||||
plotlyjs()
|
||||
@@ -387,25 +387,25 @@ plot(x, y, z, zcolor=reverse(z), markersize=3, markershape= :circle,
|
||||
|
||||
```
|
||||
|
||||
> Wir verwenden mal das `plotlyjs`-Backend, damit ist der Plot interaktiv und kann mit der Maus gedreht und gezoomt werden.
|
||||
> We use the `plotlyjs` backend here, so the plot is interactive and can be rotated and zoomed with the mouse.
|
||||
|
||||
### Plots.jl und _recipes_
|
||||
### Plots.jl and _recipes_
|
||||
|
||||
Andere Pakete können die Möglichkeiten von `Plots.jl` erweitern, indem sie sogenannte _recipes_ für spezielle Plots und Datenstrukturen definieren, siehe [https://docs.juliaplots.org/latest/ecosystem/](https://docs.juliaplots.org/latest/ecosystem/), z.B.:
|
||||
Other packages can extend the capabilities of `Plots.jl` by defining so-called _recipes_ for special plots and data structures, see [https://docs.juliaplots.org/latest/ecosystem/](https://docs.juliaplots.org/latest/ecosystem/), e.g.:
|
||||
|
||||
- `StatsPlots.jl` direktes Plotten von _Dataframes_, spezielle statistische Plots usw. oder
|
||||
- `GraphRecipes.jl` [Plotten von Graphstrukturen](https://docs.juliaplots.org/latest/GraphRecipes/examples/)
|
||||
- `StatsPlots.jl` direct plotting of _Dataframes_, special statistical plots, etc. or
|
||||
- `GraphRecipes.jl` [Plotting of graph structures](https://docs.juliaplots.org/latest/GraphRecipes/examples/)
|
||||
|
||||
|
||||
### Ein Säulendiagramm
|
||||
### A Bar Chart
|
||||
|
||||
Für das letzte Beispiel laden wir ein Paket, das über 700 freie (_"public domain"_) Datensätze, darunter z.B:
|
||||
For the last example, we load a package that provides over 700 free (_"public domain"_) datasets, including, for example:
|
||||
|
||||
- die Passagierliste der _Titanic_,
|
||||
- Verbrauchsdaten amerikanischer Autos aus den 70ern oder
|
||||
- historische Währungskurse
|
||||
- the passenger list of the _Titanic_,
|
||||
- fuel consumption data of American cars from the 70s or
|
||||
- historical exchange rates
|
||||
|
||||
bereitstellt:
|
||||
provides:
|
||||
|
||||
```{julia}
|
||||
using RDatasets
|
||||
@@ -419,13 +419,13 @@ using RDatasets
|
||||
#RDatasets.datasets()
|
||||
```
|
||||
|
||||
Der Datensatz ["Motor Trend Car Road Tests"](https://rdrr.io/r/datasets/mtcars.html)
|
||||
The dataset ["Motor Trend Car Road Tests"](https://rdrr.io/r/datasets/mtcars.html)
|
||||
|
||||
```{julia}
|
||||
cars = dataset("datasets", "mtcars")
|
||||
```
|
||||
|
||||
Wir brauchen für den Plot nur die beiden Spalten `cars.Model` und `cars.MPG`, den Benzinverbrauch in _miles per gallon_ (Mehr heißt sparsamer!)
|
||||
We only need the two columns `cars.Model` and `cars.MPG` for the plot, the fuel consumption in _miles per gallon_ (more means more economical!)
|
||||
|
||||
```{julia}
|
||||
theme(:bright)
|
||||
@@ -443,10 +443,10 @@ bar(cars.Model, cars.MPG,
|
||||
```
|
||||
|
||||
|
||||
### Was noch fehlt: Animation
|
||||
### What is Missing: Animation
|
||||
|
||||
Hier sei auf die [Dokumentation](https://docs.juliaplots.org/latest/animations/) verwiesen und nur ein Beispiel
|
||||
(von <https://www.juliafordatascience.com/animations-with-plots-jl/>) angegeben:
|
||||
Please refer to the [documentation](https://docs.juliaplots.org/latest/animations/) and only an example
|
||||
(from <https://www.juliafordatascience.com/animations-with-plots-jl/>) is given:
|
||||
|
||||
```{julia}
|
||||
#| error: false
|
||||
|
||||
Reference in New Issue
Block a user