Repository navigation
Expand file tree
/
Copy path02_1filledlines.qmd
More file actions
120 lines (89 loc) · 3.23 KB
/
Copy path02_1filledlines.qmd
File metadata and controls
120 lines (89 loc) · 3.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# Filled curves
<style>
.card {
transition: transform 0.2s ease, box-shadow 0.2s ease;
cursor: pointer;
border: 1px solid rgba(0,0,0,.125);
height: 100%;
}
.card:hover {
transform: translateY(-5px);
box-shadow: 0 8px 16px rgba(0,0,0,0.2);
}
.card-img-top {
width: 100%;
height: auto;
object-fit: cover;
}
</style>
<div class="grid">
<div class="g-col-6 g-col-md-4 g-col-lg-3">
<div class="card h-100">
<a href="02_1filledlines.html#band-plots"><img src="filled_band_thumb.png" class="card-img-top"></a>
<div class="card-body"><a href="02_1filledlines.html#band-plots" class="card-title"><strong>Band Plots</strong></a></div>
</div>
</div>
<div class="g-col-6 g-col-md-4 g-col-lg-3">
<div class="card h-100">
<a href="02_1filledlines.html#papillon"><img src="filled_papillon_thumb.png" class="card-img-top"></a>
<div class="card-body"><a href="02_1filledlines.html#papillon" class="card-title"><strong>Papillon</strong></a></div>
</div>
</div>
<div class="g-col-6 g-col-md-4 g-col-lg-3">
<div class="card h-100">
<a href="02_1filledlines.html#fill-between"><img src="filled_between_thumb.png" class="card-img-top"></a>
<div class="card-body"><a href="02_1filledlines.html#fill-between" class="card-title"><strong>Fill Between</strong></a></div>
</div>
</div>
</div>
## Band plots
The GMT *plot* module has a huge number of options. The *polygon* (-L in original) option in itself
is what other packages call `band`, so we wrapped another avatar around it and with that name too.
```{julia}
using GMT
x = -10:0.11:10;
band(x, sin.(x)./x, width=0.1, fill="green@80", show=true)
```
We could have obtained the same plot using a function as argument.
```julia
band(x->sin(x)/x, 10, width=0.1, fill="green@80", show=true)
```
Next example hides the line and plots only the bands. Since when we ask for a color fill the lines is always
plotted, the trick to no see it is to assign it full transparency. We use also a theme to change the default
tick orientation and add automatic grid lines.
```{julia}
using GMT
x = -10:0.1:10;
band(x, sin.(x), region=(-10,10,-1.5,1.5), width=0.3, pen=(0,"blue@100"),
fill="blue@80", theme=("A2atgIT"))
band!(x, cos.(x), width=0.3, pen=(0,"red@100"), fill="red@80", show=true)
```
And another example where the band is asymetric and grows in width. We had to add `eps()` to first `x`
to not have a NaN in first element of `y`.
```{julia}
using GMT
x = 0+eps():0.05:4π
y = sin.(3x) ./ (cos.(x) .+ 2)./x
band([x y], y .- 0.1 .- 0.015x, y .+ 0.1 .+ 0.03x, fill="blue@80", show=true)
```
## Papillon
```{julia}
using GMT
plot(sin, x->sin(2x), [0 2pi], fill="blue@70", pen=(1,"blue@40"), show=1)
```
## Fill between
Fill the area between the two sinc functions. Here we use the default values for line thickness
and fill color but all of that can be changed. We also add a thin white border arround tke lines.
```{julia}
using GMT
theta = linspace(-2π, 2π, 150);
y1 = sin.(theta) ./ theta;
y2 = sin.(2*theta) ./ theta;
fill_between([theta y1], [theta y2], white=true, legend="Sinc1,Sinc2", show=1)
```
```{julia}
using GMT
D = gmtread(TESTSDIR * "assets/1635541200000.dat");
D.attrib["Timecol"] = "1"; # Inform that first column has Time
fill_between(D, figsize=(16,9), yaxis=(annot=20,), theme="A0XYag", show=true)
```