Skip to content

Commit a637064

Browse files
committed
[add] matplotlib time series
1 parent 30c4ece commit a637064

File tree

5 files changed

+270
-4
lines changed

5 files changed

+270
-4
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.vscode/settings.json

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ All skills are base on the implementation of Python 3.
185185
<li><a href="#basic-single-plot">Basic (Single Plot)</li>
186186
<li><a href="#multiple-figures-and-axes">Multiple Figures and Axes</li>
187187
<li><a href="#line-plots-and-filling-area">Line Plots and Filling Area</li>
188+
<li><a href="#time-series">Time Series</li>
188189
</ul></td>
189190
</table>
190191

@@ -1939,6 +1940,28 @@ plt.fill_between(years,
19391940

19401941
## Time Series
19411942

1943+
``` py
1944+
import matplotlib.dates as mdates
1945+
1946+
plt.gca().xaxis.set_major_formatter(mdates.DateFormatter("%a, %d %m"))
1947+
plt.gca().xaxis.set_major_locator(mdates.DayLocator(interval=7))
1948+
plt.gca().xaxis.set_minor_locator(mdates.DayLocator())
1949+
1950+
plt.plot_date(dates, prices,
1951+
ls="solid",
1952+
c="orange",
1953+
marker="^",
1954+
markersize=10)
1955+
1956+
plt.grid()
1957+
plt.tight_layout()
1958+
```
1959+
1960+
![](assets/matplotlib/time_series.jpg)
1961+
1962+
- [Details 🔥](matplotlib/time_series.ipynb)
1963+
1964+
19421965
## Scatter Plots
19431966

19441967
## Bar Charts

assets/matplotlib/time_series.jpg

30 KB
Loading

matplotlib/plot_and_filling_area.ipynb

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,17 @@
1919
"%matplotlib inline"
2020
]
2121
},
22+
{
23+
"cell_type": "code",
24+
"execution_count": null,
25+
"metadata": {},
26+
"outputs": [],
27+
"source": [
28+
"years = [1.1, 1.3, 1.5, 2.0, 2.2, 2.9, 3.0, 3.2, 3.2, 3.7, 3.9, 4.0, 4.0, 4.1, 4.5, 4.9, 5.1, 5.3, 5.9, 6.0, 6.8, 7.1, 7.9, 8.2, 8.7, 9.0, 9.5, 9.6, 10.3, 10.5]\n",
29+
"\n",
30+
"salary = [39343.00, 46205.00, 37731.00, 43525.00, 39891.00, 56642.00, 60150.00, 54445.00, 64445.00, 57189.00, 63218.00, 55794.00, 56957.00, 57081.00, 61111.00, 67938.00, 66029.00, 83088.00, 81363.00, 93940.00, 91738.00, 98273.00, 101302.00, 113812.00, 109431.00, 105582.00, 116969.00, 112635.00, 122391.00, 121872.00]"
31+
]
32+
},
2233
{
2334
"cell_type": "markdown",
2435
"metadata": {},
@@ -43,10 +54,6 @@
4354
}
4455
],
4556
"source": [
46-
"years = [1.1, 1.3, 1.5, 2.0, 2.2, 2.9, 3.0, 3.2, 3.2, 3.7, 3.9, 4.0, 4.0, 4.1, 4.5, 4.9, 5.1, 5.3, 5.9, 6.0, 6.8, 7.1, 7.9, 8.2, 8.7, 9.0, 9.5, 9.6, 10.3, 10.5]\n",
47-
"\n",
48-
"salary = [39343.00, 46205.00, 37731.00, 43525.00, 39891.00, 56642.00, 60150.00, 54445.00, 64445.00, 57189.00, 63218.00, 55794.00, 56957.00, 57081.00, 61111.00, 67938.00, 66029.00, 83088.00, 81363.00, 93940.00, 91738.00, 98273.00, 101302.00, 113812.00, 109431.00, 105582.00, 116969.00, 112635.00, 122391.00, 121872.00]\n",
49-
"\n",
5057
"plt.plot(years, \n",
5158
" salary,\n",
5259
" marker=\"o\",\n",

0 commit comments

Comments
 (0)