Plotting with matplotlib in Python
Main.PythonPlots History
Hide minor edits - Show changes to output
Added line 57:
Generate a [[https://github.com/jlinehan31/Football-Field/blob/main/football_field_v1.ipynb|BYU Football field with Python]].
Deleted lines 56-73:
(:html:)
<div id="disqus_thread"></div>
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = 'apmonitor'; // required: replace example with your forum shortname
/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'https://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="https://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
(:htmlend:)
Changed lines 13-29 from:
import numpy as np
x = np.linspace(0,6,100)
y = np.sin(x)
z = np.cos(x)
import matplotlib.pyplot as plt
plt.plot(x,y,'r--',linewidth=3)
plt.plot(x,z,'k:',linewidth=2)
plt.legend(['y','z'])
plt.xlabel('x')
plt.ylabel('values')
plt.xlim([0, 3])
plt.ylim([-1.5, 1.5])
plt.savefig('myFigure.png')
plt.savefig('myFigure.eps')
plt.show()
to:
(:source lang=python:)
import numpy as np
x = np.linspace(0,6,100)
y = np.sin(x)
z = np.cos(x)
import matplotlib.pyplot as plt
plt.plot(x,y,'r--',linewidth=3)
plt.plot(x,z,'k:',linewidth=2)
plt.legend(['y','z'])
plt.xlabel('x')
plt.ylabel('values')
plt.xlim([0, 3])
plt.ylim([-1.5, 1.5])
plt.savefig('myFigure.png')
plt.savefig('myFigure.eps')
plt.show()
(:sourceend:)
import numpy as np
x = np.linspace(0,6,100)
y = np.sin(x)
z = np.cos(x)
import matplotlib.pyplot as plt
plt.plot(x,y,'r--',linewidth=3)
plt.plot(x,z,'k:',linewidth=2)
plt.legend(['y','z'])
plt.xlabel('x')
plt.ylabel('values')
plt.xlim([0, 3])
plt.ylim([-1.5, 1.5])
plt.savefig('myFigure.png')
plt.savefig('myFigure.eps')
plt.show()
(:sourceend:)
Changed lines 34-49 from:
import numpy as np
x = np.linspace(0,6,100)
y = np.sin(x)
z = np.cos(x)
%matplotlib inline
import matplotlib.pyplot as plt
plt.plot(x,y,'r--',linewidth=3)
plt.plot(x,z,'k:',linewidth=2)
plt.legend(['y','z'])
plt.xlabel('x')
plt.ylabel('values')
plt.xlim([0, 3])
plt.ylim([-1.5, 1.5])
plt.savefig('myFigure.png')
plt.savefig('myFigure.eps')
to:
(:source lang=python:)
import numpy as np
x = np.linspace(0,6,100)
y = np.sin(x)
z = np.cos(x)
%matplotlib inline
import matplotlib.pyplot as plt
plt.plot(x,y,'r--',linewidth=3)
plt.plot(x,z,'k:',linewidth=2)
plt.legend(['y','z'])
plt.xlabel('x')
plt.ylabel('values')
plt.xlim([0, 3])
plt.ylim([-1.5, 1.5])
plt.savefig('myFigure.png')
plt.savefig('myFigure.eps')
(:sourceend:)
import numpy as np
x = np.linspace(0,6,100)
y = np.sin(x)
z = np.cos(x)
%matplotlib inline
import matplotlib.pyplot as plt
plt.plot(x,y,'r--',linewidth=3)
plt.plot(x,z,'k:',linewidth=2)
plt.legend(['y','z'])
plt.xlabel('x')
plt.ylabel('values')
plt.xlim([0, 3])
plt.ylim([-1.5, 1.5])
plt.savefig('myFigure.png')
plt.savefig('myFigure.eps')
(:sourceend:)
Changed line 11 from:
!!!! Source Code
to:
!!!! Tutorial Source Code
Added lines 10-49:
!!!! Source Code
import numpy as np
x = np.linspace(0,6,100)
y = np.sin(x)
z = np.cos(x)
import matplotlib.pyplot as plt
plt.plot(x,y,'r--',linewidth=3)
plt.plot(x,z,'k:',linewidth=2)
plt.legend(['y','z'])
plt.xlabel('x')
plt.ylabel('values')
plt.xlim([0, 3])
plt.ylim([-1.5, 1.5])
plt.savefig('myFigure.png')
plt.savefig('myFigure.eps')
plt.show()
If using the iPython notebook, exclude the command '''plt.show()''' and include '''%matplotlib inline''' before loading matplotlib.pyplot as shown below.
import numpy as np
x = np.linspace(0,6,100)
y = np.sin(x)
z = np.cos(x)
%matplotlib inline
import matplotlib.pyplot as plt
plt.plot(x,y,'r--',linewidth=3)
plt.plot(x,z,'k:',linewidth=2)
plt.legend(['y','z'])
plt.xlabel('x')
plt.ylabel('values')
plt.xlim([0, 3])
plt.ylim([-1.5, 1.5])
plt.savefig('myFigure.png')
plt.savefig('myFigure.eps')
!!!! Additional Tutorials
Changed line 8 from:
<iframe width="560" height="315" src="https://www.youtube.com/embed/abL-fDq4p_o" frameborder="0" allowfullscreen></iframe>
to:
<iframe width="560" height="315" src="https://www.youtube.com/embed/xRzuzT2Kmsw" frameborder="0" allowfullscreen></iframe>
Added lines 1-30:
(:title Plotting with matplotlib in Python:)
(:keywords big data, data analysis, Python programming, matplotlib, scatter plot, graph, university course:)
(:description Plot data with Python and export for a presentation or report:)
Effective plots are important to synthesize the information into relevant and persuasive information. The following tutorial details some of the common data plotting functions within Python.
(:html:)
<iframe width="560" height="315" src="https://www.youtube.com/embed/abL-fDq4p_o" frameborder="0" allowfullscreen></iframe>
(:htmlend:)
This tutorial can also be completed with scripting programming languages like [[Main/ExcelScatterPlots|Excel]] and [[Main/MatlabPlots|MATLAB]]. Click on the appropriate link for additional information and source code.
----
(:html:)
<div id="disqus_thread"></div>
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = 'apmonitor'; // required: replace example with your forum shortname
/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'https://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="https://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
(:htmlend:)
(:keywords big data, data analysis, Python programming, matplotlib, scatter plot, graph, university course:)
(:description Plot data with Python and export for a presentation or report:)
Effective plots are important to synthesize the information into relevant and persuasive information. The following tutorial details some of the common data plotting functions within Python.
(:html:)
<iframe width="560" height="315" src="https://www.youtube.com/embed/abL-fDq4p_o" frameborder="0" allowfullscreen></iframe>
(:htmlend:)
This tutorial can also be completed with scripting programming languages like [[Main/ExcelScatterPlots|Excel]] and [[Main/MatlabPlots|MATLAB]]. Click on the appropriate link for additional information and source code.
----
(:html:)
<div id="disqus_thread"></div>
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = 'apmonitor'; // required: replace example with your forum shortname
/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'https://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="https://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
(:htmlend:)