Using graph drawing using Python's Matplotlib + Seaborn on Windows, a non-Python execution environment

Due to various circumstances, there was a case where the graph drawing function of Python was used on Windows, which is a non-Python execution environment, so it is described as a memorandum. It might be nuget, but I couldn't find out ...

environment

OS: Windows 10 64bit Python:3.6.10 Pyinstaller:3.5

Create heatmap drawing with .py

Since I want a heatmap graph this time, I created a script "heatMap.py" that draws a heatmap and saves it as .png. Eventually, .exe will be executed from Windows, so for ease of use,

  1. Read .csv (specify path)
  2. Save .png (specify path) Can be executed with arguments. Seaborn was used for heatmap drawing. The motive was it seems easy to make various heatmaps, and I felt the extensibility.

sample

import sys
import os
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt

def Heatmap(data):

 ax = sns.heatmap(data,annot=True)
 return ax

if __name__ == '__main__':

 args = sys.argv

 load_path = args[1]
 save_path = args[2]
 save_name = args[3]

 print(load_path,save_path,save_name)

 data = np.loadtxt(load_path,delimiter=",")
 hoge = Heatmap(data)
 hoge.plot()

 plt.savefig(os.path.join(save_path,save_name),facecolor="blue")   

First argument args [1]: Data source (csv file) path + file specification Second argument args [2]: Specify the path to save the graph Third argument args [3]: Graph name. Save format specified

See here for python argument execution, For the savefig path specification of matplotlib, refer to here.

Create .exe with pyinstaller

Create .exe with pyinstaller by referring to this article.

heatMap.JPG

A folder including related dlls has been created.

Run with arguments in .exe

[App.exe] [First argument] [Second argument] [Third argument]

C:\Users\user.name>heatMap.exe C:\Users\user.name\Documents\Python\Graph\DataSrc\matrix.csv C:\Users\user.name\Documents\Python\Graph\GraphDst heatMapTest.png

It's done. heatMapresult.JPG

However, it takes a few seconds to execute this because it is a policy to execute it from the beginning every time. → Actual measurement about 4 seconds Since File saving is repeated, it is not suitable for the purpose of executing this .exe on the Windows application side and importing the output file to the application side. (I can do it if it's late) Next time, make .exe always up and return it by interprocess communication

Recommended Posts

Using graph drawing using Python's Matplotlib + Seaborn on Windows, a non-Python execution environment
Using graph drawing using Python's Matplotlib + Seaborn for interprocess communication on Windows, a non-Python execution environment
Simply build a Python 3 execution environment on Windows
Until drawing a 3D graph in Python on windows10
Create a Linux environment on Windows 10
How to draw a graph using Matplotlib
Creating a python virtual environment on Windows
I built a TensorFlow environment on windows10
Run matplotlib on a Windows Docker container
Build Python3.5 + matplotlib environment on Ubuntu 12 using Anaconda
Create a Python execution environment on IBM i
Create a Python virtual development environment on Windows
Build a GVim-based Python development environment on Windows 10 (3) GVim8.0 & Python3.6
Build a Django development environment using pyenv-virtualenv on Mac
Try drawing a social graph using Twitter API v2
Create a comfortable Python 3 (Anaconda) development environment on windows
Building a TensorFlow environment that uses GPU on Windows 10
Build a GVim-based Python development environment on Windows 10 (1) Installation
Build a Python environment on your Mac using pyenv
Procedure for building a CDK environment on Windows (Python)
Build a Python development environment using pyenv on MacOS
Create a decent shell and python environment on Windows
Build a machine learning environment natively on Windows 10 (x64)
How to build a Python virtual execution environment using Visual Studio Code and pipenv on a Windows machine (also Jupyter notebook)
[Graph drawing] I tried to write a bar graph of multiple series with matplotlib and seaborn
Instantly create a diagram of 2D data using python's matplotlib
Seaborn, matplotlib garbled characters resolved in Windows10, Anaconda virtual environment
Building a Jupyter Lab development environment on WSL2 using Anaconda3
Building a Python environment on a Mac and using Jupyter lab
Build a GVim-based Python development environment on Windows 10 (2) Basic settings
Python environment construction procedure memo using Docker on Windows10 Home
Memo of Linux environment construction using VirtualBox + Vagrant on Windows 10
Until building a Python development environment using pyenv on Ubuntu 20.04
Create a Python3.4 + Nginx + uWSGI + Flask Web application execution environment with haste using pyenv on Ubuntu 12.04
Prepare Chainer environment on Windows
Try using OpenCV on Windows
Build Python environment on Windows
Django environment development on Windows 10
Build python environment on windows
[Tensorflow] Tensorflow environment construction on Windows 10
Create a Python environment for professionals in VS Code on Windows
Create a Python execution environment for Windows with VScode + Remote WSL
Build a Chainer environment using CUDA and cuDNN on a p2 instance
Build a 64-bit Python 2.7 environment with TDM-GCC and MinGW-w64 on Windows 7
The simplest way to build a Spleeter usage environment using Windows
How to build a Python environment using Virtualenv on Ubuntu 18.04 LTS
A note on using tab completion when running Python interactively on Windows
Environment construction of TensorFlow + JupyterNotebook + Matplotlib on Windows version Anaconda (August 2017 version)
Build a Python execution environment using GPU with GCP Compute engine
Everything from building a Python environment to running it on Windows