Thonny Download Mac

In this article, we show how to plot a graph with matplotlib from data from a CSV file using the CSV module in Python.

Mar 03, 2013 Description. Our website provides a free download of Thonny 3.3 for Mac. This free software for Mac OS X is an intellectual property of ee.ut. The program lies within Developer Tools, more precisely IDE. Thonny is a new Python IDE meant for teaching/learning programming. The program offers separate windows for executing function calls (helps. Download Thonny - Get familiar with the Python programming language using a novice-friendly IDE that provides you with several helpful learning tools, all packed into an intuitive GUI. Installing Thonny on a Mac using pip. 01:58 So here in the Terminal window, it’s possible to install Thonny using pip3 install thonny. Pip will download all the relevant frameworks and Thonny itself and then install Thonny. It can be run just by typing thonny. 02:15 As you can see here, Thonny is ready to run, and now we can start programming.

Thonny is a new IDE (integrated development environment) bundled with the latest version of the Raspbian with PIXEL operating system. Using Thonny, it’s now much easier to learn to code. Thonny comes with Python 3.6 built in, so you don’t need to install anything. Just open up the program, which you’ll find under Menu Programming. We’ll be using the 2D plotting library, matplotlib, which was originally written by John D. Hunter and since then has become a very active open-source development community project. It allows you to generate high quality line plots, scatter plots, histograms, bar charts, and much more.

So basically you won't always be plotting graphs straight up from a Python IDLE by typing in that data.

Python Download

Many times, the data that you want to graph is found in some type of file, such as a CSV file (comma-separated values file).

Using the CSV module in Python, we can import a CSV file, read it, and extract the data from it, such as the x-axis data and the y-axis data.

We can then use matplotlib in order to plot the graph of the extracted data.

So what we have to do is create a CSV file. This can either be done with a high-level software such as Microsoft Excel or it can be done with a simple editor such as notepad. In this example, I actually create my CSV file with notepad. I save it with a .txt file extension.

I create a very basic CSV file, consisting of an x-axis that goes from 1 to 5.

These 5 data points have y-axis values.

This CSV file is shown at the following link: Example CSV File

Remember to place this CSV file in the folder that Python is running in. To see which folder this is, import the os module and type in, os.getcwd()

This will get the current directory that Python is operating in.

Place the CSV file in this directory, or change the directory to another one using the os.chdir() function.

So below, we read and extract data from this CSV file and then plot the data using matplotlib.

So the first thing we have to do is import matplotlib. We do this with the line, import matplotlib.pyplot as plt


We then have to import the csv module, since we use this module in order to read a CSV file. This is done using the line, import csv

We then have the variable, x, which we set equal to an empty list.

We then have the variable, y, which we set equal to an empty list, as well.

We then are able to open the CSV file with the line, with open('csvfile1.txt', 'r') as csvfile.

This is like a file handle. It doesn't read the file, but it allows us to open the file to be able to read it. 'r' means read. This file handle is reference by csvfile.

We then have a variable, plots, which we set equal to, csv.read(csvfile, delimiter=',')

This reads the CSV file.

We then have a for loop that goes through each rows of the plot data.

The delimiter is a comma, so data gets separated by the comma found in the CSV file.

Thonny Download Mac Os

We append to the variable, x, which is a list using the append() function. Into this function, we pass in, int(row[0])

This takes the data before the comma on each line and appends it to the x variable.

We then append to the variable, y, which is a list using the append() function. Into this function, we pass in, int(row[1])

This takes the data after the comma on each line and appends it to the y variable.

We now have our x and y variables populated.

This ends the file reading and the extraction of data.

We now go on to focus completely on the plotting of the graph.

Thonny Matplotlib Image

We plot a line graph with the plt.plot() function.

We specify x and y and we add a marker so that each data point contains a marker.

We give the graph a title, x label, and y label.

Thonny Download For Mac

We then show the plot.

Once we run this code, we get the following output shown below.

And this is how to plot a graph with matplotlib from a CSV file using the CSV module in Python.

Related Resources

Thonny Download For Mac

How to Randomly Select From or Shuffle a List in Python

Thonny Download Last Version Free

Thonny Matplotlib Download

Thonny Download Mac Free

Most Viewed Posts