A Rhino Remote library that brings Seaborn (Matplotlib) inside of Grasshopper using Hops.
This second version is a complete refactor of the seaborn-grasshopper implementation. This approach greatly improves from the first version in the following ways:
- Additional fuctions added
despine
Dictionary with "Despine" functions arguments, that removes top and right axis lines.add_args
Use additional figure arguments are not implemented in Grasshopper.ax_args
Implement axis arguments to the matplotlib.Axis element. (Set title, x and y limits, etc )fig_size
Change figure size
- Ready for web deployment using Heroku and gunicorn
- Export image as a encoded b64 string
- Less code duplication
- Correct handling of defaults
- Style improvement
Requirements
- Git: Version control is an important tool when working on projects, and Git is one of the most popular and widely-used version control systems. You can download Git here.
- Virtual Environment Manager: This guide uses conda, but you can also use miniconda or other virtual environment managers. You can download conda here.
- Clone the repository using the following command:
git clone https://github.com/monsieurpablo/seaborn_grasshopper
The command above will download the repository containing the code for the server and its dependencies.
- Navigate to the repository
cd seaborn_grasshopper
This command will take you inside the repository's folder, where you will be able to access the files and folders required to run the server.
- Create a virtual environment with
Python 3.9
usingconda
conda create --name ghseaborn python=3.9
conda activate ghseaborn
Conda allows you to create virtual environments, which are isolated spaces where you can install packages and dependencies without interfering with your system's Python installation. The first command creates an environment named ghseaborn with Python 3.10, and the second command activates the environment so that any packages you install will be installed in that environment.
- Install the dependencies listed in the requirements file:
pip install -r requirements.txt
This command will install all the packages and dependencies required to run the server, as listed in the requirements.txt file.
- Install
waitress
as a server handler (Windows only)
pip install waitress
Waitress is a lightweight web server that can be used to run the server. This command installs the waitress package, which is required to run the server on Windows.
- Start the server
waitress-serve --threads 6 --listen=*:5000 app:app
This command starts the server and makes it available on the localhost at port 5000. The --threads flag specifies the number of threads to use and the --listen flag specifies the IP address and port to listen on.
- Connect to the server in Grasshopper
Use the the following URL address: http://127.0.0.1:5000/ in the panel asking for the server address.
Congratulations!!!!! You can now connect to the server using the URL address provided and start using Seaborn with Grasshopper 3D.
From now on you can start the server by running the command waitress-serve --threads 6 --listen=*:5000 app:app
from the repository's folder.
Follow this tutorial. The code is already set-up to work with Render.