This is a simple example of how to show graphs in VS Code using Matplotlib, Jupyter, Materialize, and Plotly.
- Install the Jupyter extension in VS Code.
- Install the Python extension in VS Code.
-
Create a new virtual environment:
python -m venv .venv
-
Activate the virtual environment:
-
On Windows:
.venv\Scripts\Activate.ps1
-
On macOS and Linux:
source .venv/bin/activate
-
-
Install the necessary packages:
pip install psycopg2-binary matplotlib plotly pandas python-dotenv nbformat
Copy the .env.example
file to a new file named .env
and fill in the necessary information.
Run the SQL statements in the demo.sql
file to create the necessary table, view, and insert some data.
This demo will show you how to create and display a graph using Matplotlib in VS Code.
-
Open the
demo_matplotlib.py
file and run the code. -
Right-click on the code and select "Run in Interactive Window" -> "Run current file in Interactive Window".
-
VS Code will open a new tab with the graph:
-
To display your own graph, change the SQL query in the
demo_matplotlib.py
file to query your own data and the Matplotlib code to display the graph you want to show.
This demo will show you how to create and display a graph using Plotly and Pandas in VS Code. Plotly provides interactive and visually appealing charts, which can be a great alternative to Matplotlib.
-
Open the
demo_plotly.py
file in VS Code. -
Right-click on the code and select "Run in Interactive Window" -> "Run current file in Interactive Window".
-
VS Code will open a new tab or your web browser with the interactive graph.
-
To display your own graph, change the SQL query in the
demo_plotly.py
file to query your own data and the Plotly code to display the graph you want to show.