From 8f3e01340da5c043d2f3143b6d146105dba1589e Mon Sep 17 00:00:00 2001 From: Dietrich Brunn Date: Fri, 13 Jan 2017 22:36:46 +0100 Subject: [PATCH] Made some changes to showcase plots plots. * removed ugly pie chart * changed fontsize of labels in scatter plot * changed y-range in sine plot to work around bounding box problem. --- .../pie_and_polar_charts/pie_demo_features.py | 26 +------------------ examples/pylab_examples/scatter_demo2.py | 4 +-- examples/pylab_examples/simple_plot.py | 2 +- 3 files changed, 4 insertions(+), 28 deletions(-) diff --git a/examples/pie_and_polar_charts/pie_demo_features.py b/examples/pie_and_polar_charts/pie_demo_features.py index 89750ca6c162..cfb6b124ba52 100644 --- a/examples/pie_and_polar_charts/pie_demo_features.py +++ b/examples/pie_and_polar_charts/pie_demo_features.py @@ -16,7 +16,6 @@ rotated counter-clockwise by 90 degrees, and the frog slice starts on the positive y-axis. """ -import numpy as np import matplotlib.pyplot as plt # Pie chart, where the slices will be ordered and plotted counter-clockwise: @@ -24,32 +23,9 @@ sizes = [15, 30, 45, 10] explode = (0, 0.1, 0, 0) # only "explode" the 2nd slice (i.e. 'Hogs') -fg1, ax1 = plt.subplots() +fig1, ax1 = plt.subplots() ax1.pie(sizes, explode=explode, labels=labels, autopct='%1.1f%%', shadow=True, startangle=90) ax1.axis('equal') # Equal aspect ratio ensures that pie is drawn as a circle. - -# Plot four Pie charts in a 2x2 grid: -pie_data = [np.roll(sizes, i) for i in range(4)] # generate some data -pie_centerpos = [(0, 0), (0, 1), (1, 0), (1, 1)] # the grid positions - -fg2, ax2 = plt.subplots() -for data, cpos in zip(pie_data, pie_centerpos): - _, txts = ax2.pie(data, explode=explode, shadow=True, startangle=90, - radius=0.35, center=cpos, frame=True, labeldistance=.7) - # Make texts include number and labels: - for t, l, d in zip(txts, labels, data): - t.set_text("%s\n %.1f%%" % (l, d)) - t.set_horizontalalignment("center") - t.set_fontsize(8) - -ax2.set_xticks([0, 1]) -ax2.set_yticks([0, 1]) -ax2.set_xticklabels(["Sunny", "Cloudy"]) -ax2.set_yticklabels(["Dry", "Rainy"]) -ax2.set_xlim((-0.5, 1.5)) -ax2.set_ylim((-0.5, 1.5)) -ax2.set_aspect('equal') # Equal aspect ratio ensures that the pie is a circle. - plt.show() diff --git a/examples/pylab_examples/scatter_demo2.py b/examples/pylab_examples/scatter_demo2.py index 2cc2a9d56e7d..34b4ef63fb04 100644 --- a/examples/pylab_examples/scatter_demo2.py +++ b/examples/pylab_examples/scatter_demo2.py @@ -21,8 +21,8 @@ fig, ax = plt.subplots() ax.scatter(delta1[:-1], delta1[1:], c=close, s=volume, alpha=0.5) -ax.set_xlabel(r'$\Delta_i$', fontsize=20) -ax.set_ylabel(r'$\Delta_{i+1}$', fontsize=20) +ax.set_xlabel(r'$\Delta_i$', fontsize=15) +ax.set_ylabel(r'$\Delta_{i+1}$', fontsize=15) ax.set_title('Volume and percent change') ax.grid(True) diff --git a/examples/pylab_examples/simple_plot.py b/examples/pylab_examples/simple_plot.py index 8afbbea53f46..758f42bca2f9 100644 --- a/examples/pylab_examples/simple_plot.py +++ b/examples/pylab_examples/simple_plot.py @@ -2,7 +2,7 @@ import numpy as np t = np.arange(0.0, 2.0, 0.01) -s = np.sin(2*np.pi*t) +s = 1 + np.sin(2*np.pi*t) plt.plot(t, s) plt.xlabel('time (s)')