Categories
gimlet fremantle menu

what line of code will import matplotlib

trying to import the packages through cmd (opening a python console in cmd) and vscode throw different errors. The installation seems very fine until Ive encountered this problem. Learn more. It gets or sets the y-axis limits of the current axes. Matplotlib is a plotting library for the Python programming language and its numerical mathematics extension NumPy. Read Matplotlib 1.3.1 requires nose which is not installed. Itcan be used in python scripts, shell, web application servers and othergraphical user interface toolkits. And so on. Step 2 ? What line of code will import matplotlib? Being a die hard animal lover is the only trait, he is proud of. I tried: plot(x, 'b:+', x**2, 'r-o') and worked. 5.) , , : from matplotlib.patches import Patch import. A Beginner's Guide to learn web scraping with python! Matplotlib Line Previous Next Linestyle. - and then " python -m pip install matplotlib ". I have discussedaboutmultiple types of plots in python matplotlib suchas bar plot, scatter plot, pie plot, area plot etc. Pyplot provides the state-machine interface to the underlying plotting library in matplotlib. Assignees. In this lesson, we will briefly discuss the imports and configurations required throughout the rest of this course. Your email address will not be published. To verify that matplotlib is successfully installed on your system, execute the following command in the command prompt. The full command for importing this is below: Let's test that matplotlib has been installed correctly by creating a very basic line plot. What does "you better" mean in this context of conversation? . subplot. rev2023.1.18.43173. What are Generators in Python and How to use them? Letter of recommendation contains wrong name of journal, how will this hurt my application? . Required fields are marked *. Each pyplot function makes some change to a figure: e.g., creates a figure, creates a plotting area in a figure, plots some lines in a plotting area, decorates the plot with labels, etc. Visualization using Matplotlib generally consists of bars, pies, lines, scatter plots and so on. First, let us understand why do we need a bar graph. import matplotlib.pyplot as plt import numpy as np xpoints . pyplot is a collection of command style functions that make matplotlib work like MATLAB. Init In Python: Everything You Need To Know, Learn How To Use Split Function In Python. from matplotlib import pyplot as plt is the same as. Matplotlib is a plotting library for the Python programming language and its numerical mathematics extension NumPy. The data is displayed as a collection of points, each having the value of one variable which determines the position on the horizontal axis and the value of other variable determines the position on the vertical axis. With the line of code that you have considered, you say that the variable ax is the first of the four axes to which you want to start plotting. The ball, for instance, will feel the force of gravity pulling it downward, the force of the ground pushing it upward direction it is rolling. Django vs Flask: Which is the best for your Web Application? Copyright 2022 it-qa.com | All rights reserved. Dark code. Step 3 Check if it is installed successfully. WHAT ARE YOUR SALARY EXPECTATIONS? __version__) 2.2.3. How do I import a project into Android Studio. Top 10 Best IDE for Python: How to choose the best Python IDE? Let me implement it practically, consider the below example. Above, we used import matplotlib.pyplot as plt to import the pyplot module from matplotlib and name it plt. 2. The Image functions available in matplotlib are as follows: You can customize the axes properties by using the image functions available in matplotlib which are mentioned as follows: You can create, save, and display a figure in matplotlib by using the given following functions: You may like the following Python Matplotlib tutorials: In this Python tutorial, we have discussed what is matplotlib library, and how to use it in Python and also covered the following topics: Python is one of the most popular languages in the United States of America. In myprevious blog, I discussedabout anumerical library of python called, Learning to use this library efficiently is also an essential part of. Please mention it in the comments section of this Python Matplotlib blog and we will get back to you as soon as possible. Some of them are separate downloads, others can be shipped with the matplotlib source code but have external dependencies. 3 How to install Matplotlib in VS Code tutorial? The code to import matplotlib is as follows:-- Importing the matplotlib library import matplotlib -- Importing the matplotlib library and alias it with a shorter name import matplotlib as plt. By clicking Post Your Answer, you agree to our terms of service, privacy policy and cookie policy. It is a collection of command-style functions that make matplotlib work like MATLAB. Line magics are prefixed with the % character and work much like OS command-line calls: they get as an argument the rest of the line, where arguments are passed without parentheses or quotes. The code below creates a more advanced histogram. TELL ME ABOUT YOURSELF. Consider the below example: Usually we need scatter plots in order to compare variables, for example, how much onevariable is affected by another variable to build a relation out of it. What is it. The parallel component of the force of gravity is not balanced by any other force. Matplotlib has a variety of modules available for import. Also, the important thing to keep in mind is that longer the bar, greater is the value. WHAT HAPPENED? Tutorials. The code to import matplotlib is as follows: In the above code, reference name (alias) can be any of your choices, but the most commonly used name is plt. What is it. 4.) Step 3 ? To plot any line plot () method is used in Matplotlib. Now, bin refers to the range of values that are divided into series of intervals. Energy is conserved in rolling motion without slipping. If you are working through this course on a Mac that has a Retina display, you may notice that the chart we just created is pretty blurry. Here we go. The data is displayed as a collection of points having high income low salary and low income high salary. Pyplot is a collection of functions in the popular visualization package Matplotlib. They're typically instruments for reasoning about quantitative information. What is Python JSON and How to implement it? To learn more, see our tips on writing great answers. Debian / Ubuntu: sudo apt-get install python3-matplotlib. When the above command is executed, a dependency of the package, subprocess32 may be compiled. Advertisement. Questions and Answers the OJT First, let's create the script that we'll be working with in this tutorial: scatter.py. Stay tuned! Lets see how to implement some of the basic plots mentioned above on some sample data, so open up jupyter notebook or any Ipython shell and lets do some examples: Read: Matplotlib is currently using agg a non-gui backend. Next, let us move forward in thisblog and explore different types of plots available in python matplotlib. Questions and Answers the OJT and answer the following: How to import a Python module given the full path? Double-sided tape maybe? WHY DO YOU WANT THIS JOB? GREATEST WEAKNESS? All Rights Reserved, Matplotlib is one of the most popular Python packages used for, matplotlib. Simple line plot. Type the following commands in the command prompt to check is python and pip is installed on your system. The change in speed on slopes is due to gravity. Python vs C: Know what are the differences, Python vs C++: Know what are the differences. like, In Python functions that are not "builtin", i.e. Introduction to Atom Python Text Editor and how to configure it. WHAT IS YOUR GREATEST S What are Lambda Functions and How to Use Them? 5 Is it possible to import Matplotlib in Python? Let's again refer to iPython's documentation: "With this backend, the output of plotting commands is displayed inline within frontends like the Jupyter notebook, directly below the code cell that produced it. (adsbygoogle = window.adsbygoogle || []).push({}); Copyright 2023 Find what come to your mind. Here's some basic code to generating one of the most simple graphs that we can, it will take us only 3 lines. What are Comments in Python and how to use them? Area plots are pretty much similar to the line plot. So subplot (221)is identical to subplot (2,2,1). Enjoy unlimited access on 5500+ Hand Picked Quality Video Courses. It is a cross-platform library that provides various tools to create 2D plots from the data in lists or arrays in python. It is used in data visualization and graphical plotting. In [1]: import matplotlib print('matplotlib: {}'. How we can import Python modules in Jython? IPython provides a collection of several predefined functions called magic functions, which can be used and called by command-line style syntax.Basically, there are two types of magic functions, line-oriented and cell-oriented. How To Convert Lists To Strings In Python? First of all, make sure you have python and pip preinstalled on your system. So even if the slope is same for both objects, a massive object moves faster through the slope than a less mass object. 7.) Upcoming Batches For Python Certification Training Course. It is an extension to it, and not a substitute. These two lists will be used as the dataset for our matplotlib graph. It provides such tools that can be used to create publication-standard plots and figures in variety of export formats and various environments (pycharm, jupyter notebook) across platforms. Type of graph: Where you have to define the type of the plot, can be a bar chart, line chart, histogram, etc. What would you suggest him to execute code and display chart successfully? The library itself is huge, at something like 70,000 total lines of code. Let me first tell you the difference between a bar graph and a histogram. You can see in the above code that we have used the %matplotlib inline magic command, which means that it will show different kinds of charts inside the Jupyter . To use matplotlib, we need to install it. Ltd. All rights Reserved. And show the graph: Here, you will display the graph. If matplotlib is successfully installed, the version of matplotlib will be displayed. 9.) Python Seaborn Tutorial: What is Seaborn and How to Use it? How To Best Utilize Python CGI In Day To Day Coding? # import section import pandas as pd import numpy as np import matplotlib.pyplot as plt from matplotlib.animation import FuncAnimation from datetime import datetime, timedelta plt.style.use('fivethirtyeight') # dataframe creation . Some of them are listed below: We have come to an end of this python matplotlibtutorial. 8.) It sets the label of the y-axis of the current axes. How to import a single function from a Python module? ARE YOU WILLING TO RELOCATE OR TRANSFER TO OTHER PLACE FOR WORK? This page is a free excerpt from my $199 course Python for Finance, which is 50% off for the next 50 students. . So, we will also use it. Getting started with the OneCompiler's Python editor is easy and fast. 9.) How To Best Implement Multiprocessing In Python? Important Python Data Types You Need to Know, PyCharm Tutorial: Writing Python Code In PyCharm (IDE), Python Visual Studio- Learn How To Make Your First Python Program. You can do it so, by executing the following command: If the Python package is not installed for all users in your system then, you have to install Microsoft Visual C++ 2008 (64 bit or 32 bit for Python 2.7) or Microsoft Visual C++ 2010 (64 bit or 32 bit for Python 3.4). TELL ME ABOUT YOURSELF. 6 How to install Matplotlib on Visual Studio Code? Python and Netflix: What Happens When You Stream a Film? I tried to use the minimum code possible. The code is pretty much similar to the previous examples that you have seen but there is one new concept here i.e. pyplot is a collection of command style functions that, To verify that Matplotlib is installed, try to. Matplotlib is a plotting library for the Python programming language and its numerical mathematics extension NumPy. Each pyplot function makes some change to a figure: e.g., creates a figure, creates a plotting area in a figure, plots some lines in a plotting area, decorates the plot with labels, etc. Matplotlib is a Python library that helps to plot graphs. 2. ln, = plt.plot (x, y, '-') plt.axis ( [0, 100, 0, 10]) The plt.plot () returns a special Line object, used for drawing line graphs. It sets the scaling of the y-axis of the current axes. Code Example - import matplotlib.pyplot as plt. When a rolling object, such as a ball or something on wheels, goes down a hill it will speed up. How to Check a Number is Palindrome in Python? Python 3.6.9. Bug report Bug summary Can't import matplotlib.pyplot Code for reproduction import matplotlib.pyplot as plt Actual outcome # If applicable, paste the console output here -----. It gets or sets the y-limits of the current tick locations and labels. First import matplotlib and numpy, these are useful for charting. A: Simply put, gravity is a force that acts betweem the Earth and the ball, pulling them together. What is print in Python and How to use its Parameters? This library can be installed with the following command: pip install matplotlib. Lets have a look at the below example: In the above pie chart, I have divided the circle into4 sectors or slices which represents the respective category (playing, sleeping, eating and working) along with the percentage they hold. Python Iterators: What is Iterator in Python and how to use it? A complete matplotlib python histogram. python plot graph x and y. It is basically used to show the percentage or proportional data where each slice of pie represents acategory. First, import the pyplot module. pip install matplotlib. But when I type pip list, there is no matplotlib package in the list. Agree Area plots are pretty much similar to the line plot. Just what I needed to get started! 2023 Brain4ce Education Solutions Pvt. IPython, Jupyter, and matplotlib modes . __version__) 2.2.3. . import matplotlib matplotlib.matplotlib_fname() Next, you can pull up . It is the name assigned to a file when it is saved. It is used in data visualization and graphical plotting?.How to install matplotlib in Python? python matplotlib.pyplot add graphs. How to rename a file based on a directory name? Next, let us move to our last yet most frequently used plot Pie chart. A technophile who likes writing about different technologies and spreading knowledge. import matplotlib.pyplot as plt # initializing the data. What if you want to change the width or color of a particular line or what if you want to have some grid lines, there you need styling! We are going to explore matplotlib in interactive mode covering most common cases. Consider the below code: As we can see in the above image, we have time spent based on the categories. You can specify conditions of storing and accessing cookies in your browser. Matplotlib can be installed using pip. How we can import Python modules without installing? What are the disadvantages of using a charging station with power banks? Here we are going to provide you the code for it. . slices of pie. Step 1 Make sure Python and pip is preinstalled on your system. This is great, but it can also make the library very confusing to use. Code Example, zero padding to numbers in column str_pad rlang Code, Component not re-rendering on array state change Code, Ways to run javascript on your computer Code Example, component is changing controlled input to be uncontrolled -. Then, run the following pip command in the command prompt to install Matplotlib. Now, let us import Matplotlib and plot some random data points. . Th. Energy is not conserved in rolling motion with slipping due to the heat generated by kinetic friction. In [3]: import matplotlib print(matplotlib. Thank you Hannes. WHAT ARE YOUR SALARY EXPECTATIONS? To call the package module, we begin our code with import matplotlib.pyplot as plt. Decorates the plot with labels, annotations, etc. To verify that Matplotlib is installed, try to invoke Matplotlib's version at the Python REPL. The subplot() command specifies numrow, numcol, fignum which ranges from 1 to numrows*numcols. WHAT HAPPENED? It is the parallel component of the force of gravity that causes this acceleration. By clicking Accept all cookies, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy. Matplotlib is a Python module for plotting. format(matplotlib. import matplotlib. . Code, How to create a simple list in React Native? - and then " python -m pip install matplotlib", This site is using cookies under cookie policy . The editor shows sample boilerplate code when . explanation of matplotlib is very easiest and its very helpfull for me thank you. You can use matplotlib and utilize its functionalities in python by simply importing it into your environment (Jupiter notebook, google collab, IDLE, etc). How to check installed version of Matplotlib. In this case the line. Regular Expression in Python With Example, Object Oriented Programming Python: All you need to know, Python Class Object Oriented Programming. Let's test that matplotlib has been installed correctly by creating a very basic line plot. Then, in our script, let's import matplotlib. Save my name, email, and website in this browser for the next time I comment. The first two parameters are the lists for the x and y axis of the graph. so you can start practicing now. A rolling object?s velocity v is directly related to its angular velocity ? # Importing Libraries import opendatasets as od import pandas as pd import matplotlib.pyplot as plt import plotly.express as px import numpy as np # Setting the dataset to . Now, let us import Matplotlib and plot some random data points. Simple, isnt it? It builds on top of Matplotlib, introducing some additional plot types and provides some visual improvements to some plots and graphs. This is Akash Mittal, an overall computer scientist. This Edureka Python Matplotlib tutorial explains what is data visualization and how to perform data visualization using Matplotlib. The following are eq. It gets or sets the x-limits of the current tick locations and labels. Python Requests Module Tutorial Sending HTTP Requests Using Requests Module, Django Tutorial Web Development with Python Django Framework. (Butit can be used from Juliavia PyPlot package). - type " python -m pip install pip ". Let us see how can we add title, labels to our graph created by python matplotlib library to bring in more meaning to it. Seaborn is built on top of Matplotlib. How to fix object has no attribute error in Python? Next, let us understandarea plot or you can also say Stack plot using python matplotlib. Answer (1 of 4): Syntac error suggests that you afe typing something wrong, and that its not merely mis-spelling the name of the module. 3.) Each pyplot function makes some change to a figure: e.g., creates a figure, creates a plotting area in a figure, plots some lines in a plotting area, decorates the plot with labels, etc. Once you can successfully import matplotlib, then you are ready to continue. Raj has written following code to create a bar chart-Import matplotlib.pyplot as plt weekdays = ['sun','mon','tue'] sale = [1234,3312,2541] plt.bar(weekdays, sale) But when executing this code he is not able to display any chart. 4.) which will import all functions (symbols) into the global namespace, and you can now use your original line: Your call to plot() is wrong, and the ValueError is telling you so. plt.grid: Configure the grid lines in the figure. Lines magics can return results and can be used in the right hand side of an assignment. Matplotlib is a cross-platform, data visualization and graphical plotting library for Python and its numerical extension NumPy. Dark code. We can create different types of 3D plots like scatter plots, contour plots, surface plots, etc. Installation and configuration of Python and Visual Studio Code has been perfomed by following this step by step guide. # example data. What is the Format Function in Python and How does it work? Matplotlib can be used to represent line plots, bar plots, histograms, scatter plots and much more. WHAT IS YOUR AMBITION? Here is the code: Since I am simply repeating the commands shown in the tutorial I can not understand what I am doing wrong. It would need more lines of code to make it more professional, but it's readable . WHEN WAS THE LAST TIME YOU WERE ANGRY? How To Test That Matplotlib Has Installed Correctly. It can be represented horizontally or vertically. Each pyplot function makes some change to the plot (figure). Therefore, subplots helps us to plot multiplegraphs in which you can define it by aligning vertically or horizontally. Matplotlib is a plotting library for the Python programming language and its numerical mathematics extension NumPy. Here is the code: from matplotlib.pyplot import * import numpy as np import pandas as pd x = np.arange(100) lines = plot(x, 'linear', 'g:+', x, 'square','r-o') ValueError: x and y must have same first dimension . Required fields are marked *. Asking for help, clarification, or responding to other answers. How To Create Your First Python Metaclass? These are special functions that only work in iPython notebooks (like Jupyter). Step 1 ? 1 What line of code will import matplotlib? For example, Matplotlib is a cross-platform library that can be used in various python scripts, any python shell (available in IDLE, pycharm, etc) and IPython shells (cond, jupyter notebook), the web application servers (Django, flask), and various GUI toolkits (, And if you are working on some old version of. Browse other questions tagged, Where developers & technologists share private knowledge with coworkers, Reach developers & technologists worldwide. subplot. Matploitlib is a Python Library used for plotting, this python library provides and objected-oriented APIs for integrating plots into applications. Hey - Nick here! HOW MANY HOURS DO YOU NORMALLY WORK PER WEEK? Each pyplot function makes some change to a figure: e.g., creates a figure, creates a plotting area in a figure, plots some lines in a plotting area, decorates the plot with labels, etc. But anyway there is no python package called pyplot. This means that the visualizations we produce will show directly in our Jupyter Notebook instead of opening in a separate window. Software Developer & Professional Explainer. 6.) Now, if you have noticed these slicesadds up to 24 hrs, but the calculation of pie slices is done automatically for you. Below is the detail: Is there such a thing as Pyplot in Python? It is one of the most powerful plotting libraries in Python. You can give any name, but plt is standard and most commonly used. 4.) The matplotlib.pyplot is the collection command style functions that make matplotlib feel like working with MATLAB. Using it for drawing a chart - import matplotlib.pyplot as plt plt.plot([1,2,3,4]) plt.ylabel('some numbers') plt.show() Source: Pyplot Tutorial Its functions manipulate elements of a figure, such as creating a figure, creating a plotting area, plotting lines, adding plot labels, etc. We use cookies to ensure that we give you the best experience on our website. Please do not copy search and your idea. What is difference between matplotlib and matplotlib Pyplot? import matplotlib.pyplot as plt. WHY WE SHOULD HIRE YOU? __version__)) matplotlib: 2.2.3. Plots helps to understand trends, patterns, and to make correlations. 1. This corresponds to the second line in the plot that is orange. It gets or sets the x-axis limits of the current axes. It is often convenient to create the Axes together with the Figure, but you can also manually add Axes later on. A function can create a figure: matplotlib.pyplot.figure(), Another function that creates a plotting area in a figure: matplotlib.pyplot.plot(). I have been working with Python for a long time and I have expertise in working with various libraries on Tkinter, Pandas, NumPy, Turtle, Django, Matplotlib, Tensorflow, Scipy, Scikit-Learn, etc I have experience in working with various clients in countries like United States, Canada, United Kingdom, Australia, New Zealand, etc. matplotlib.pyplot is a python package used for 2D graphics. Code, How to hide the status bar in React native? Matplotlib is the basic visualizing or plotting library of the python programming language. Ruby vs Python : What are the Differences? The short answer is yes, you should always import Matplotlib if you are using Seaborn. You can use the keyword argument linestyle, or shorter ls, to change the style of the plotted line: Example. Matplotlib is probably the most used Python package for 2D-graphics. In [5]: import matplotlib as mpl print(mpl. pyplot is a collection of command style functions that make matplotlib work like MATLAB. Matplotlib is the whole package; pylab is a module in matplotlib that gets installed alongside matplotlib; and matplotlib. In the above example, I have aligned it horizontally. There are variousplots which can be created using python matplotlib. WHAT ARE YOUR SALARY EXPECTATIONS? Line chart examples Line chart. What is the Average Python Developer Salary? You can use the plot(x,y) method to create a line chart. Join Edureka Meetup community for 100+ Free Webinars each month. Data Structures You Need To Learn In Python, Python Programming Beginners Guide To Python Programming Language. Python By SimTheGreat on Jun 29 2020. import matplotlib.pyplot as plt %matplotlib inline plt.plot(data) #this is not nessisary but makes your plot more readable plt.ylabel('y axis means .') plt.xlabel('x axis means .') 3. by writing few lines of code in python. Install Python On Windows Python 3.X Installation Guide. 10.) So, let me show you how to add style to a graph using python matplotlib. It uses fewer syntax and has easily interesting default themes. WHAT IS YOUR AMBITION? Threading In Python: Learn How To Work With Threads In Python. Next, let us move to our last yet most frequently used plot Pie chart. WHEN WAS THE LAST TIME YOU WERE ANGRY? Python For Loop Tutorial With Examples To Practice, While Loop In Python : All You Need To Know. before every plot call you could instead do. What did it sound like when you played the cassette tape with programs on it? Step 1 Make sure Python and pip is preinstalled on your system. The third hex color code is #2ca02c. Its functions manipulate elements of a figure, such as creating a figure, creating a plotting area, plotting lines, adding plot labels, etc. First, create a basic dataset with the range function: Next, plot this data using pyplot's plot method: If your output looks like this, then you can proceed! Python Functions : A Complete Beginners Guide, Learn How To Use Map Function In Python With Examples, Python time sleep() One Stop Solution for time.sleep() Method, How To Sort A Dictionary In Python : Sort By Keys , Sort By Values, String Function In Python: How To Use It with Examples, How To Convert Decimal To Binary In Python, Python Tuple With Example: Everything You Need To Know, How to Reverse a List in Python: Learn Python List Reverse() Method, Learn What is Range in Python With Examples, Everything You Need To Know About Hash In Python. x format plot python. import numpy as np. When I try python2.7 -c 'import matplotlib; print matplotl. To get in-depth knowledge on python along with its various applications, you canenrollfor live Python online training by Edureka with 24/7 support and lifetime access. It was created and coded by John D. Hunter in Python programming language in 2003. In the above code, reference name (alias) can be any of your choices, but the most commonly used name is plt. 10.) Your email address will not be published. TELL ME ABOUT A TIME YOU MADE A MISTAKE? TRENGTH? Here is more information on magic functions from the iPython documentation: "IPython has a set of predefined magic functions that you can call with a command line style syntax. Use a dotted line: import matplotlib.pyplot as plt import numpy as np ypoints = np.array([3, 8, 1, 10]) The current stable version of matplotlib is 3.4.2, that released on 8 May 2021. vitag.videoDiscoverConfig = { random: true, noFixedVideo: true }; (vitag.Init = window.vitag.Init || []).push(function () { viAPItag.initInstreamBanner("vi_2114589801") }); (vitag.Init = window.vitag.Init || []).push(function () { viAPItag.display("vi_2114589807") }), (vitag.Init = window.vitag.Init || []).push(function () { viAPItag.display("vi_2114590547") }), (vitag.Init = window.vitag.Init || []).push(function () { viAPItag.display("vi_2114590548") }), (vitag.Init = window.vitag.Init || []).push(function () { viAPItag.display("vi_2114590549") }), (vitag.Init = window.vitag.Init || []).push(function () { viAPItag.display("vi_2114590550") }), (vitag.Init = window.vitag.Init || []).push(function () { viAPItag.display("vi_2114590551") }), (vitag.Init = window.vitag.Init || []).push(function () { viAPItag.display("vi_2114590552") }), (vitag.Init = window.vitag.Init || []).push(function () { viAPItag.display("vi_2114590553") }), how to link javascript to html Code Example, How to disable the toggle switch in React Native?

Which El Pato Sauce Is The Mildest, Wyrmwood Location Dq11, Please Forward This Email To Anyone That I've Missed, Western Mail Obituaries Carmarthen, When To Pick Hot Burrito Peppers, Dr Freda Crews Dr Phil, Does He Like Me Back Quiz Middle School, How To Cite Victorian Early Years Learning And Development Framework, Los Angeles County Pre Approved Adu Plans, Gilligan's Island Cast Still Alive 2020, Things To Do In Bunbury With Dogs, Travis Rosbach Wife,

what line of code will import matplotlib