10
10
np.set_printoptions(precision = 4 , suppress = True )
11
11
pd.options.display.max_rows = 15
12
12
import matplotlib
13
- matplotlib.style.use(' ggplot ' )
13
+ matplotlib.style.use(' seaborn ' )
14
14
import matplotlib.pyplot as plt
15
15
plt.close(' all' )
16
16
@@ -24,12 +24,12 @@ We use the standard convention for referencing the matplotlib API:
24
24
25
25
import matplotlib.pyplot as plt
26
26
27
- The plots in this document are made using matplotlib's ``ggplot `` style (new in version 1.4 ):
27
+ The plots in this document are made using matplotlib's ``seaborn `` style (new in version 1.5 ):
28
28
29
29
.. code-block :: python
30
30
31
31
import matplotlib
32
- matplotlib.style.use(' ggplot ' )
32
+ matplotlib.style.use(' seaborn ' )
33
33
34
34
We provide the basics in pandas to easily create decent looking plots.
35
35
See the :ref: `ecosystem <ecosystem.visualization >` section for visualization
@@ -134,7 +134,7 @@ For example, a bar plot can be created the following way:
134
134
plt.figure();
135
135
136
136
@savefig bar_plot_ex.png
137
- df.iloc[5 ].plot(kind = ' bar' ); plt.axhline( 0 , color = ' k ' )
137
+ df.iloc[5 ].plot(kind = ' bar' );
138
138
139
139
.. versionadded :: 0.17.0
140
140
@@ -1049,6 +1049,46 @@ be colored differently.
1049
1049
Plot Formatting
1050
1050
---------------
1051
1051
1052
+ Setting the plot style
1053
+ ~~~~~~~~~~~~~~~~~~~~~~~~
1054
+
1055
+ From version 1.5 and up, matplotlib offers a range of preconfigured plotting style. Setting these
1056
+ these styles can be used to easily give the plots have the general look that you want.
1057
+ Setting the can style is as easy as calling ``matplotlib.style.use(my_plot_style) `` before
1058
+ creating your plot.
1059
+
1060
+ Some examples of popular styles beside ``'seaborn' `` are:
1061
+
1062
+ **default **. The ``default `` style is available from matplotlib v.2.0:
1063
+
1064
+ .. ipython :: python
1065
+
1066
+ df = pd.DataFrame(np.random.randn(1000 , 4 ), index = ts.index, columns = list (' ABCD' ))
1067
+ df = df.cumsum()
1068
+
1069
+ matplotlib.style.use(' default' )
1070
+
1071
+ @savefig series_plot_default.png
1072
+ df.plot()
1073
+
1074
+ **ggplot **. ``ggplot `` is a very popular style and has been available in matplotlib longer than other styles.
1075
+
1076
+ .. ipython :: python
1077
+
1078
+ matplotlib.style.use(' ggplot' )
1079
+
1080
+ @savefig series_plot_ggplot.png
1081
+ df.plot()
1082
+
1083
+ The names of the various available styles are listed at ``matplotlib.style.available `` and it can be worth it
1084
+ to familiarize yourself with them.
1085
+
1086
+ .. ipython :: python
1087
+
1088
+ matplotlib.style.available
1089
+ # resetting style to seaborn
1090
+ matplotlib.style.use(' seaborn' )
1091
+
1052
1092
Most plotting methods have a set of keyword arguments that control the
1053
1093
layout and formatting of the returned plot:
1054
1094
@@ -1082,9 +1122,6 @@ shown by default.
1082
1122
1083
1123
.. ipython :: python
1084
1124
1085
- df = pd.DataFrame(np.random.randn(1000 , 4 ), index = ts.index, columns = list (' ABCD' ))
1086
- df = df.cumsum()
1087
-
1088
1125
@savefig frame_plot_basic_noleg.png
1089
1126
df.plot(legend = False )
1090
1127
0 commit comments