Created
March 28, 2020 07:05
-
-
Save stephenmm/aae538fcf8e8ca683408966ae3f37c93 to your computer and use it in GitHub Desktop.
How to go from bare windows machine to plotting graphs in Python (Amazingly complicated but should be very repeatable...)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/home/smeckley/py/venvs/venv1/bin/python | |
# All the steps required to get this simple plot: | |
# 1) Install VM VirtualBox on my windows machine | |
# 2) Download LinuxMixt (LMDE4) .iso | |
# 3) Create new VM for Linux Ubuntu and load .iso into the virtual optical drive | |
# 4) Startup the VM and click on "install" icon on the desktop (follow propmts) | |
# 5) Once finished with the basic install we need to enable "Guest Additions" to share clipboard/resize screen (all the goodies) VM->Devices->"Install Guest Additions CD Image" and run that | |
# 6) Install gvim (WTF!!) "sudo apt install vim-gtk3" | |
# 7) Get Python working with the correct libraries | |
# sudo su | |
# update-alternatives --install /usr/bin/python python /usr/bin/python3 1; # Sets python3 as the default | |
# exit | |
# sudo apt install python3-pip | |
# sudo apt install python3-venv | |
# sudo apt-get install python3-tk | |
# mkdir -p ~/py/venvs/ | |
# pushd ~/py/venvs/ | |
# python -m venv venv1 | |
# source ~/py/venvs/venv1/bin/activate | |
# python -m pip install numpy scipy matplotlib ipython jupyter pandas sympy nose | |
# 8) Create this file and go! Easy peasy..... | |
import matplotlib | |
import matplotlib.pyplot as plt | |
import numpy as np | |
# Data for plotting | |
t = np.arange(0.0, 2.0, 0.01) | |
s = 1 + np.sin(2 * np.pi * t) | |
fig, ax = plt.subplots() | |
ax.plot(t, s) | |
ax.set(xlabel='time (s)', ylabel='voltage (mV)', | |
title='About as simple as it gets, folks') | |
ax.grid() | |
fig.savefig("test.png") | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment