From 355f3a320839c5b78cd7e6f8c15e07ca4d7e81ba Mon Sep 17 00:00:00 2001 From: ash13 Date: Thu, 19 Oct 2017 12:49:53 +0530 Subject: [PATCH 1/3] Added description to widget example programs except Cursor and Menu --- examples/widgets/buttons.py | 2 +- examples/widgets/check_buttons.py | 2 +- .../widgets/lasso_selector_demo_sgskip.py | 1 + examples/widgets/multicursor.py | 2 +- examples/widgets/radio_buttons.py | 2 +- examples/widgets/slider_demo.py | 2 +- examples/widgets/slider_demo1.py | 55 +++++++++++++++++++ examples/widgets/textbox.py | 2 +- 8 files changed, 62 insertions(+), 6 deletions(-) create mode 100644 examples/widgets/slider_demo1.py diff --git a/examples/widgets/buttons.py b/examples/widgets/buttons.py index 6420b6022f7c..dcedebfaa720 100644 --- a/examples/widgets/buttons.py +++ b/examples/widgets/buttons.py @@ -2,7 +2,7 @@ ======= Buttons ======= - +An pretty cool example to show how to use buttons widget.The program shows a simple GUI with a sine wave changing its frequency.The next and previous button widget used here helps shows the wave with new frequency. """ import numpy as np diff --git a/examples/widgets/check_buttons.py b/examples/widgets/check_buttons.py index 856b6b4f4a55..fd814d50979a 100644 --- a/examples/widgets/check_buttons.py +++ b/examples/widgets/check_buttons.py @@ -2,7 +2,7 @@ ============= Check Buttons ============= - +This program shows the use of 'Check Buttons' which is similar to our usual check boxes. There are 3 different sine waves which are shown and by checking the boxes, we can choose which waves we want to see. """ import numpy as np import matplotlib.pyplot as plt diff --git a/examples/widgets/lasso_selector_demo_sgskip.py b/examples/widgets/lasso_selector_demo_sgskip.py index 8fc8f02517d2..aad253a515bd 100644 --- a/examples/widgets/lasso_selector_demo_sgskip.py +++ b/examples/widgets/lasso_selector_demo_sgskip.py @@ -2,6 +2,7 @@ =================== Lasso Selector Demo =================== +An example to show the Lasso Selector widget. The graph shows a scatter plot. You can select a few points by drawing a lasso loop around the points on the graphjust like any other Lasso tool. To draw, just click on the graph,hold and drag it around the points you need to select. """ from __future__ import print_function diff --git a/examples/widgets/multicursor.py b/examples/widgets/multicursor.py index c49ac716fa1a..58650e2696ac 100644 --- a/examples/widgets/multicursor.py +++ b/examples/widgets/multicursor.py @@ -2,7 +2,7 @@ =========== Multicursor =========== - +An example to show multiple cursors. The graph has two subplots and on hovering over the cursor over the two seperate graphs, the values are shown respectively. """ import numpy as np import matplotlib.pyplot as plt diff --git a/examples/widgets/radio_buttons.py b/examples/widgets/radio_buttons.py index fe5d3d7b6e45..f7cb655fc4bd 100644 --- a/examples/widgets/radio_buttons.py +++ b/examples/widgets/radio_buttons.py @@ -2,7 +2,7 @@ ============= Radio Buttons ============= - +An example to show how radio buttons widget can be used in the plots. The radio button in this program helps you choose one of the three different sine waves to be shown in the plot. """ import numpy as np import matplotlib.pyplot as plt diff --git a/examples/widgets/slider_demo.py b/examples/widgets/slider_demo.py index f106ce66dc42..c99fc5f8be70 100644 --- a/examples/widgets/slider_demo.py +++ b/examples/widgets/slider_demo.py @@ -2,7 +2,7 @@ =========== Slider Demo =========== - +An example to show the use of slider widget. In this example, slider is used to choose the frequency of the wave. """ import numpy as np import matplotlib.pyplot as plt diff --git a/examples/widgets/slider_demo1.py b/examples/widgets/slider_demo1.py new file mode 100644 index 000000000000..a1ae7fdd8d78 --- /dev/null +++ b/examples/widgets/slider_demo1.py @@ -0,0 +1,55 @@ +""" +=========== +Slider Demo +=========== + +""" +import numpy as np +import matplotlib.pyplot as plt +from matplotlib.widgets import Slider, Button, RadioButtons + +fig, ax = plt.subplots() +plt.subplots_adjust(left=0.25, bottom=0.25) +t = np.arange(0.0, 1.0, 0.001) +a0 = 5 +f0 = 3 +delta_f = 5.0 +s = a0*np.sin(2*np.pi*f0*t) +l, = plt.plot(t, s, lw=2, color='red') +plt.axis([0, 1, -10, 10]) + +axcolor = 'lightgoldenrodyellow' +axfreq = plt.axes([0.25, 0.1, 0.65, 0.03]) +axamp = plt.axes([0.25, 0.15, 0.65, 0.03]) + +sfreq = Slider(axfreq, 'Freq', 0.1, 30.0, valinit=f0, valstep=delta_f) +samp = Slider(axamp, 'Amp', 0.1, 10.0, valinit=a0) + + +def update(val): + amp = samp.val + freq = sfreq.val + l.set_ydata(amp*np.sin(2*np.pi*freq*t)) + fig.canvas.draw_idle() +sfreq.on_changed(update) +samp.on_changed(update) + +resetax = plt.axes([0.8, 0.025, 0.1, 0.04]) +button = Button(resetax, 'Reset', color=axcolor, hovercolor='0.975') + + +def reset(event): + sfreq.reset() + samp.reset() +button.on_clicked(reset) + +rax = plt.axes([0.025, 0.5, 0.15, 0.15], facecolor=axcolor) +radio = RadioButtons(rax, ('red', 'blue', 'green'), active=0) + + +def colorfunc(label): + l.set_color(label) + fig.canvas.draw_idle() +radio.on_clicked(colorfunc) + +plt.show() diff --git a/examples/widgets/textbox.py b/examples/widgets/textbox.py index d05936dd6405..3c148e68d3f6 100644 --- a/examples/widgets/textbox.py +++ b/examples/widgets/textbox.py @@ -2,7 +2,7 @@ ======= Textbox ======= - +An example to show the use of textbox widget. You can use it mention any text that needs to be displayed or formulas or values. You can further use it to take input from the user, and use a submit button to create plots using the given input(Just a use case). """ import numpy as np From 7f5c07b8ada3a2edf04872f05d7863f85d3589e9 Mon Sep 17 00:00:00 2001 From: ash13 Date: Thu, 19 Oct 2017 14:46:58 +0530 Subject: [PATCH 2/3] Fixed documentation typos in the widget example programs --- examples/widgets/buttons.py | 2 +- .../widgets/lasso_selector_demo_sgskip.py | 2 +- examples/widgets/multicursor.py | 2 +- examples/widgets/radio_buttons.py | 2 +- examples/widgets/slider_demo1.py | 55 ------------------- examples/widgets/textbox.py | 2 +- 6 files changed, 5 insertions(+), 60 deletions(-) delete mode 100644 examples/widgets/slider_demo1.py diff --git a/examples/widgets/buttons.py b/examples/widgets/buttons.py index dcedebfaa720..4c3af3fda51b 100644 --- a/examples/widgets/buttons.py +++ b/examples/widgets/buttons.py @@ -2,7 +2,7 @@ ======= Buttons ======= -An pretty cool example to show how to use buttons widget.The program shows a simple GUI with a sine wave changing its frequency.The next and previous button widget used here helps shows the wave with new frequency. +The program shows a simple GUI with a sine wave changing its frequency.The next and previous button widget used here helps shows the wave with new frequency. """ import numpy as np diff --git a/examples/widgets/lasso_selector_demo_sgskip.py b/examples/widgets/lasso_selector_demo_sgskip.py index aad253a515bd..9f1bc8b8a57b 100644 --- a/examples/widgets/lasso_selector_demo_sgskip.py +++ b/examples/widgets/lasso_selector_demo_sgskip.py @@ -2,7 +2,7 @@ =================== Lasso Selector Demo =================== -An example to show the Lasso Selector widget. The graph shows a scatter plot. You can select a few points by drawing a lasso loop around the points on the graphjust like any other Lasso tool. To draw, just click on the graph,hold and drag it around the points you need to select. +An example to show the use of Lasso Selector widget. The graph shows a scatter plot. You can select a few points by drawing a lasso loop around the points on the graphjust like any other Lasso tool. To draw, just click on the graph,hold and drag it around the points you need to select. """ from __future__ import print_function diff --git a/examples/widgets/multicursor.py b/examples/widgets/multicursor.py index 58650e2696ac..5c5ed45e2463 100644 --- a/examples/widgets/multicursor.py +++ b/examples/widgets/multicursor.py @@ -2,7 +2,7 @@ =========== Multicursor =========== -An example to show multiple cursors. The graph has two subplots and on hovering over the cursor over the two seperate graphs, the values are shown respectively. +A program to show multiple cursors. The graph has two subplots and on hovering the cursor over the two seperate graphs, the values are shown respectively. """ import numpy as np import matplotlib.pyplot as plt diff --git a/examples/widgets/radio_buttons.py b/examples/widgets/radio_buttons.py index f7cb655fc4bd..9cc677d12b12 100644 --- a/examples/widgets/radio_buttons.py +++ b/examples/widgets/radio_buttons.py @@ -2,7 +2,7 @@ ============= Radio Buttons ============= -An example to show how radio buttons widget can be used in the plots. The radio button in this program helps you choose one of the three different sine waves to be shown in the plot. +A program to show how radio buttons widget can be used in the plots. The radio button in this program helps you choose one of the three different sine waves to be shown in the plot. """ import numpy as np import matplotlib.pyplot as plt diff --git a/examples/widgets/slider_demo1.py b/examples/widgets/slider_demo1.py deleted file mode 100644 index a1ae7fdd8d78..000000000000 --- a/examples/widgets/slider_demo1.py +++ /dev/null @@ -1,55 +0,0 @@ -""" -=========== -Slider Demo -=========== - -""" -import numpy as np -import matplotlib.pyplot as plt -from matplotlib.widgets import Slider, Button, RadioButtons - -fig, ax = plt.subplots() -plt.subplots_adjust(left=0.25, bottom=0.25) -t = np.arange(0.0, 1.0, 0.001) -a0 = 5 -f0 = 3 -delta_f = 5.0 -s = a0*np.sin(2*np.pi*f0*t) -l, = plt.plot(t, s, lw=2, color='red') -plt.axis([0, 1, -10, 10]) - -axcolor = 'lightgoldenrodyellow' -axfreq = plt.axes([0.25, 0.1, 0.65, 0.03]) -axamp = plt.axes([0.25, 0.15, 0.65, 0.03]) - -sfreq = Slider(axfreq, 'Freq', 0.1, 30.0, valinit=f0, valstep=delta_f) -samp = Slider(axamp, 'Amp', 0.1, 10.0, valinit=a0) - - -def update(val): - amp = samp.val - freq = sfreq.val - l.set_ydata(amp*np.sin(2*np.pi*freq*t)) - fig.canvas.draw_idle() -sfreq.on_changed(update) -samp.on_changed(update) - -resetax = plt.axes([0.8, 0.025, 0.1, 0.04]) -button = Button(resetax, 'Reset', color=axcolor, hovercolor='0.975') - - -def reset(event): - sfreq.reset() - samp.reset() -button.on_clicked(reset) - -rax = plt.axes([0.025, 0.5, 0.15, 0.15], facecolor=axcolor) -radio = RadioButtons(rax, ('red', 'blue', 'green'), active=0) - - -def colorfunc(label): - l.set_color(label) - fig.canvas.draw_idle() -radio.on_clicked(colorfunc) - -plt.show() diff --git a/examples/widgets/textbox.py b/examples/widgets/textbox.py index 3c148e68d3f6..eab693d6ba66 100644 --- a/examples/widgets/textbox.py +++ b/examples/widgets/textbox.py @@ -2,7 +2,7 @@ ======= Textbox ======= -An example to show the use of textbox widget. You can use it mention any text that needs to be displayed or formulas or values. You can further use it to take input from the user, and use a submit button to create plots using the given input(Just a use case). +It shows the use of textbox widget. You can use it mention any text that needs to be displayed or formulas or values. You can further use it to take input from the user, and use a submit button to create plots using the given input(Just a use case). """ import numpy as np From cf356ac1dbe4157f5f708af91cabe480e5871764 Mon Sep 17 00:00:00 2001 From: Chris Holdgraf Date: Sat, 21 Oct 2017 10:51:16 -0700 Subject: [PATCH 3/3] cleaning up wording and pep --- examples/widgets/buttons.py | 6 +++++- examples/widgets/check_buttons.py | 7 ++++++- examples/widgets/lasso_selector_demo_sgskip.py | 6 +++++- examples/widgets/multicursor.py | 7 ++++++- examples/widgets/radio_buttons.py | 7 ++++++- examples/widgets/slider_demo.py | 7 ++++++- examples/widgets/textbox.py | 7 ++++++- 7 files changed, 40 insertions(+), 7 deletions(-) diff --git a/examples/widgets/buttons.py b/examples/widgets/buttons.py index 4c3af3fda51b..833366d33a0b 100644 --- a/examples/widgets/buttons.py +++ b/examples/widgets/buttons.py @@ -2,7 +2,11 @@ ======= Buttons ======= -The program shows a simple GUI with a sine wave changing its frequency.The next and previous button widget used here helps shows the wave with new frequency. + +Constructing a simple button GUI to modify a sine wave. + +The ``next`` and ``previous`` button widget helps visualize the wave with +new frequencies. """ import numpy as np diff --git a/examples/widgets/check_buttons.py b/examples/widgets/check_buttons.py index fd814d50979a..d9f06192dd43 100644 --- a/examples/widgets/check_buttons.py +++ b/examples/widgets/check_buttons.py @@ -2,7 +2,12 @@ ============= Check Buttons ============= -This program shows the use of 'Check Buttons' which is similar to our usual check boxes. There are 3 different sine waves which are shown and by checking the boxes, we can choose which waves we want to see. + +Turning visual elements on and off with check buttons. + +This program shows the use of 'Check Buttons' which is similar to +check boxes. There are 3 different sine waves shown and we can choose which +waves are displayed with the check buttons. """ import numpy as np import matplotlib.pyplot as plt diff --git a/examples/widgets/lasso_selector_demo_sgskip.py b/examples/widgets/lasso_selector_demo_sgskip.py index 9f1bc8b8a57b..4b73d4b3b906 100644 --- a/examples/widgets/lasso_selector_demo_sgskip.py +++ b/examples/widgets/lasso_selector_demo_sgskip.py @@ -2,8 +2,12 @@ =================== Lasso Selector Demo =================== -An example to show the use of Lasso Selector widget. The graph shows a scatter plot. You can select a few points by drawing a lasso loop around the points on the graphjust like any other Lasso tool. To draw, just click on the graph,hold and drag it around the points you need to select. +Interactively selecting data points with the lasso tool. + +This examples plots a scatter plot. You can then select a few points by drawing +a lasso loop around the points on the graph. To draw, just click +on the graph, hold, and drag it around the points you need to select. """ from __future__ import print_function diff --git a/examples/widgets/multicursor.py b/examples/widgets/multicursor.py index 5c5ed45e2463..5137512065f8 100644 --- a/examples/widgets/multicursor.py +++ b/examples/widgets/multicursor.py @@ -2,7 +2,12 @@ =========== Multicursor =========== -A program to show multiple cursors. The graph has two subplots and on hovering the cursor over the two seperate graphs, the values are shown respectively. + +Showing a cursor on multiple plots simultaneously. + +This example generates two subplots and on hovering +the cursor over data in one subplot, the values of that datapoint +are shown in both respectively. """ import numpy as np import matplotlib.pyplot as plt diff --git a/examples/widgets/radio_buttons.py b/examples/widgets/radio_buttons.py index 9cc677d12b12..41cde39bdfb8 100644 --- a/examples/widgets/radio_buttons.py +++ b/examples/widgets/radio_buttons.py @@ -2,7 +2,12 @@ ============= Radio Buttons ============= -A program to show how radio buttons widget can be used in the plots. The radio button in this program helps you choose one of the three different sine waves to be shown in the plot. + +Using radio buttons to choose properties of your plot. + +Radio buttons let you choose between multiple options in a visualization. +In this case, the buttons let the user choose one of the three different sine +waves to be shown in the plot. """ import numpy as np import matplotlib.pyplot as plt diff --git a/examples/widgets/slider_demo.py b/examples/widgets/slider_demo.py index c99fc5f8be70..48c20db69e1b 100644 --- a/examples/widgets/slider_demo.py +++ b/examples/widgets/slider_demo.py @@ -2,7 +2,12 @@ =========== Slider Demo =========== -An example to show the use of slider widget. In this example, slider is used to choose the frequency of the wave. + +Using the slider widget to control visual properties of your plot. + +In this example, a slider is used to choose the frequency of a sine +wave. You can control many continuously-varying properties of your plot in +this way. """ import numpy as np import matplotlib.pyplot as plt diff --git a/examples/widgets/textbox.py b/examples/widgets/textbox.py index eab693d6ba66..b3c786014b6c 100644 --- a/examples/widgets/textbox.py +++ b/examples/widgets/textbox.py @@ -2,7 +2,12 @@ ======= Textbox ======= -It shows the use of textbox widget. You can use it mention any text that needs to be displayed or formulas or values. You can further use it to take input from the user, and use a submit button to create plots using the given input(Just a use case). + +Allowing text input with the Textbox widget. + +You can use the Textbox widget to let users provide any text that needs to be +displayed, including formulas. You can use a submit button to create plots +with the given input. """ import numpy as np