Skip to content

Commit 30c4ece

Browse files
committed
[add] matplotlib plot and filling area
1 parent 75af08a commit 30c4ece

File tree

8 files changed

+285
-20
lines changed

8 files changed

+285
-20
lines changed

README.md

Lines changed: 65 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ All skills are base on the implementation of Python 3.
184184
<td><ul style="margin: 8px">
185185
<li><a href="#basic-single-plot">Basic (Single Plot)</li>
186186
<li><a href="#multiple-figures-and-axes">Multiple Figures and Axes</li>
187+
<li><a href="#line-plots-and-filling-area">Line Plots and Filling Area</li>
187188
</ul></td>
188189
</table>
189190

@@ -1863,48 +1864,92 @@ plt.annotate("wow \nmax", xy=(16, 1), xytext=(40, 0.9), arrowprops={"facecolor":
18631864
plt.annotate("wow \nmax again", xy=(78, 1), xytext=(95, 0.9), arrowprops={"facecolor": "red", "shrink": 0.05})
18641865
```
18651866

1867+
![](assets/matplotlib/basic.jpg)
1868+
18661869
- [Details 🔥](matplotlib/basic.ipynb)
18671870

18681871
## Multiple Figures and Axes
18691872

18701873
``` py
1871-
# Pyplot style
1872-
plt.figure(1)
1873-
plt.plot(...)
1874-
1875-
plt.figure(2)
1876-
plt.subplot(2, 1, 1)
1877-
plt.plot(...)
1878-
plt.subplot(2, 1, 2)
1879-
plt.plot(...)
1880-
1881-
18821874
# Object-oriented style
18831875
fig1, ax = plt.subplots()
18841876
ax.plot(...)
18851877

18861878
fig2, axs = plt.subplots(2, 1)
18871879
axs[0].plot(...)
18881880
axs[1].plot(...)
1881+
1882+
1883+
# Pyplot style
1884+
plt.figure(1)
1885+
plt.title("Figure 1")
1886+
1887+
plt.figure(2)
1888+
plt.subplot(311)
1889+
plt.title("Figure 2")
1890+
1891+
plt.subplot(323)
1892+
plt.subplot(324)
1893+
1894+
plt.subplot(337)
1895+
plt.subplot(338)
1896+
plt.subplot(339)
18891897
```
18901898

1899+
<p float="left">
1900+
<img src="assets/matplotlib/figure1.jpg" width="350" />
1901+
<img src="assets/matplotlib/figure2.jpg" width="350" />
1902+
</p>
1903+
18911904
- [Details 🔥](matplotlib/figures_axes.ipynb)
18921905

1893-
## Style
1906+
## Line Plots and Filling Area
1907+
1908+
``` py
1909+
# Line Plots
1910+
plt.plot(years,
1911+
salary,
1912+
marker="o",
1913+
markersize=5,
1914+
lw=2,
1915+
ls="-",
1916+
)
1917+
1918+
1919+
# Filling Areas
1920+
plt.fill_between(years,
1921+
salary,
1922+
salary_mean,
1923+
where=(salary > salary_mean),
1924+
alpha=.4,
1925+
color="green",
1926+
edgecolor="black",
1927+
interpolate=True,
1928+
label="On Average"
1929+
)
1930+
```
1931+
1932+
<p float="center">
1933+
<img src="assets/matplotlib/line_plots.jpg" width="260" />
1934+
<img src="assets/matplotlib/filling_area.jpg" width="260" />
1935+
<img src="assets/matplotlib/filling_area_with_mean.jpg" width="260" />
1936+
</p>
1937+
1938+
- [Details 🔥](matplotlib/plot_and_filling_area.ipynb)
1939+
1940+
## Time Series
18941941

1942+
## Scatter Plots
18951943

1944+
## Bar Charts
18961945

1946+
## Pie Charts
18971947

1898-
<!-- plot - fill
1899-
bar
1900-
pie
1901-
stack
1902-
histogram - distribution
1903-
scatter
1904-
time series
1905-
image -->
1948+
## Histograms
19061949

1950+
## Stack Plots
19071951

1952+
## Image
19081953

19091954
# TODOs
19101955

assets/matplotlib/basic.jpg

32.9 KB
Loading

assets/matplotlib/figure1.jpg

9.59 KB
Loading

assets/matplotlib/figure2.jpg

20.7 KB
Loading

assets/matplotlib/filling_area.jpg

19.6 KB
Loading
21.6 KB
Loading

assets/matplotlib/line_plots.jpg

20.4 KB
Loading

matplotlib/plot_and_filling_area.ipynb

Lines changed: 220 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)