Until drawing a 3D graph in Python on windows10

Drawing 3D graphs in Python

There was a request to draw a 3D graph in a nice way, and when I looked up "How can I write it in a nice way ...", it came out that it could be drawn with Python's matplotlib. So, this time I will write from installing Python to drawing a 3D graph.

Python 2.7 installation

There are many articles about installation, so I will omit it. I entered it with reference to the following.

Installing python in windows environment

However, because Windows 10 is bad or my PC is bad, Python Path does not pass in the environment variable, so add the following path.

C:\\Python27

pip installation

It became super easy before I knew it! Just go to the following site, download "get-pip.py" and execute it.

Installing with get-pip.py

Start the command prompt, move to the location where you downloaded get-pip.py, and execute the following command to enter pip.

python get-pip.py

Install what you need

Install numpy for data organization and matplotlib for drawing.

python -m pip install numpy
python -m pip install matplotlib

Now you are ready.

Drawing program

For the drawing program, I referred to the following site. Draw 3D graph with matplotlib

from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np

#Range and spacing settings
x = np.arange(-5, 5, 0.25)
y = np.arange(-5, 5, 0.25)

#Mesh drawing settings
X, Y = np.meshgrid(x, y)

#Calculation
Z = np.sin(X)+ np.cos(Y)

fig = plt.figure()
ax = Axes3D(fig)

#plot
ax.plot_wireframe(X,Y,Z)

plt.show()

Execution result

figure_1.png

If I can do it so far, I think I should just learn how to handle numpy ...? I managed to figure out how to draw in 3D, so I'm struggling to plot the results processed by OpenCV.

Recommended Posts

Until drawing a 3D graph in Python on windows10
Graph drawing in python
Hit a command in Python (Windows)
Create a Python environment for professionals in VS Code on Windows
Python on Windows
Try drawing a simple animation in Python
[Python] [Windows] Take a screen capture in Python
Creating a python virtual environment on Windows
Solve ABC165 A, B, D in Python
Introducing a library that was not included in pip on Python / Windows
Using graph drawing using Python's Matplotlib + Seaborn on Windows, a non-Python execution environment
Draw a graph of a quadratic function in Python
Draw a "breast curved surface" in a 3D graph (1)
Simply build a Python 3 execution environment on Windows
From file to graph drawing in Python. Elementary elementary
A note on optimizing blackbox functions in Python
Draw a "breast curved surface" in a 3D graph (2)
Create a Python virtual development environment on Windows
python basic on windows ②
Install python on windows
Draw graph in python
Build a GVim-based Python development environment on Windows 10 (3) GVim8.0 & Python3.6
Build a Python extension for E-Cell 4 on Windows 7 (64bit)
Create a comfortable Python 3 (Anaconda) development environment on windows
Build a GVim-based Python development environment on Windows 10 (1) Installation
Until you insert data into a spreadsheet in Python
Procedure for building a CDK environment on Windows (Python)
A note on handling variables in Python recursive functions
Write a log-scale histogram on the x-axis in python
Create a decent shell and python environment on Windows
Until you create a machine learning environment with Python on Windows 7 and run it
Set-enable Python virtualenv on Windows
Take a screenshot in Python
Run Openpose on Python (Windows)
Drawing candle charts in python
Create a function in Python
Install watchdog on Windows + Python 3.3
Python + Kivy development on Windows
Sphinx-autobuild (0.5.2) on Windows7, Python 3.5.1, Sphinx 1.3.5
Fastest Python installation on Windows
Build Python environment on Windows
Solve ABC175 D in Python
Make a bookmarklet in Python
Build python environment on windows
AtCoder ABC 182 Python (A ~ D)
I ran python on windows
Draw a heart in Python
[Python] [Chainer] [Windows] Install Chainer on Windows
Python install in 2 lines @Windows
Use Python on Windows (PyCharm)
Until you create Python Virtualenv on Windows and launch Jupyter
Create a list in Python with all followers on twitter
Detect "temperature (using A / D converter)" using python on Raspberry Pi 3!
A memo when creating a directed graph using Graphviz in Python
A note on touching Microsoft's face recognition API in Python
Build a GVim-based Python development environment on Windows 10 (2) Basic settings
Print PDF in Python on Windows: Use an external application
Until building a Python development environment using pyenv on Ubuntu 20.04
VScode environment construction (on Mac) & graph display in Python (@browser)
Using graph drawing using Python's Matplotlib + Seaborn for interprocess communication on Windows, a non-Python execution environment
Building a Python environment on Mac