0% found this document useful (0 votes)
5 views4 pages

1python Chart Properties

Uploaded by

David Osei
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)
5 views4 pages

1python Chart Properties

Uploaded by

David Osei
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

PYTHON ­ CHART PROPERTIES

[Link] Copyright © [Link]

Advertisements

Python has excellent libraries for data visualization. A combination of Pandas, numpy and matplotlib can help
in creating in nearly all types of visualizations charts. In this chapter we will get started with looking at some
simple chart and the various properties of the chart.

Creating a Chart
We use numpy library to create the required numbers to be mapped for creating the chart and the pyplot method
in matplotlib to draws the actual chart.

import numpy as np
import [Link] as plt

x = [Link](0,10)
y = x ^ 2
#Simple Plot
[Link](x,y)

Its output is as follows −


Labling the Axes
We can apply labels to the axes as well as a title for the chart using appropriate methods from the library as shown
below.

import numpy as np
import [Link] as plt

x = [Link](0,10)
y = x ^ 2
#Labeling the Axes and Title
[Link]("Graph Drawing")
[Link]("Time")
[Link]("Distance")
#Simple Plot
[Link](x,y)

Its output is as follows −

Formatting Line type and Colour


The style as well as colour for the line in the chart can be specified using appropriate methods from the library as
shown below.
import numpy as np
import [Link] as plt

x = [Link](0,10)
y = x ^ 2
#Labeling the Axes and Title
[Link]("Graph Drawing")
[Link]("Time")
[Link]("Distance")

# Formatting the line colors


[Link](x,y,'r')

# Formatting the line type


[Link](x,y,'>')

Its output is as follows −

Saving the Chart File


The chart can be saved in different image file formats using appropriate methods from the library as shown below.

import numpy as np
import [Link] as plt

x = [Link](0,10)
y = x ^ 2
#Labeling the Axes and Title
[Link]("Graph Drawing")
[Link]("Time")
[Link]("Distance")

# Formatting the line colors


[Link](x,y,'r')

# Formatting the line type


[Link](x,y,'>')

# save in pdf formats


[Link]('[Link]', format='pdf')

The above code creates the pdf file in the default path of the python environment.

You might also like