0% found this document useful (0 votes)
32 views1 page

Machine Exercise 10: GUI - Graphing II: GE 120 2019-20 2nd Semester

This document provides instructions for a machine exercise to create a GUI application using PySimpleGUI and matplotlib to plot a given curve. The application will have three buttons: Plot, Cancel, and About. When Plot is clicked, it will plot the curve sin(x)+cos(x) from 0 to 2π in a matplotlib window. Cancel closes the application, and About shows a popup with a description. The application must generate x and y-values to plot the curve, using functions that take parameters for the start, end, and number of intervals. It must also import matplotlib and use math module functions like pi.

Uploaded by

Joshua Macaldo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views1 page

Machine Exercise 10: GUI - Graphing II: GE 120 2019-20 2nd Semester

This document provides instructions for a machine exercise to create a GUI application using PySimpleGUI and matplotlib to plot a given curve. The application will have three buttons: Plot, Cancel, and About. When Plot is clicked, it will plot the curve sin(x)+cos(x) from 0 to 2π in a matplotlib window. Cancel closes the application, and About shows a popup with a description. The application must generate x and y-values to plot the curve, using functions that take parameters for the start, end, and number of intervals. It must also import matplotlib and use math module functions like pi.

Uploaded by

Joshua Macaldo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

GE 120 2019-20 2nd Semester

Machine Exercise 10: GUI – Graphing II

Objectives:
• To use PySimpleGUI to provide GUI.
• To use matplotlib to plot a given curve

Implement an application with GUI using PySimpleGUI that graphs a given curve
displayed in a matplotlib window.

Do the above as follows:

1. Install via pip command the module matplotlib as it is a third-party module.


2. Refer to the PySimpleGUI Cookbook section entitled Matplotlib Window with GUI
Window. The main GUI would be a window with 3 buttons: Plot, Cancel and About
(instead of Popup as the button’s label)
• When Plot button is clicked, the graph of the curve sin(x)+cos(x) from x = 0 to 2π (in
radians) is plotted in a Matplotlib Window.
• The Cancel button closes the entire application.
• The About button when clicked shows a popup message describing what the
application does.
3. As x-values between the first and last x-values are needed, define a function that
generates x-values between x0 (the first), and xn (the last), where n is the number of
intervals. Call thus function gen_xs with 3 parameters: x0, xn, and n. The return value
is a list of the generated x-values including x0 and xn. For the problem, n should be
sufficiently large so the graph is accurate enough.
4. Similarly, define the function gen_ys that takes, as parameter, a list of x-values, and
calculates for each x-value the value of the above mentioned curve. The list of
generated y-values is the returned value.
5. Use the math module to evaluate the curve at the generated x-values, and also to have
access to the value of pi.
6. Modify the function draw_plot to receive, as parameters, two lists: a list of x-values,
and a list of y-values. Note that when you call plt.plot, the first two parameters should
be the lists passed to draw_plot.

Lastly, submit your Python file properly named to include the string GE120ME10 plus
your surname, and first and middle name initials.
---------- END ----------

You might also like