← all conversations

Python Dashboard Visualization Guide

2025-07-064 turns13,339 charsgpt-4o
data-visualizationdashboard-designpython-scripting

Summary

The user wants to generate a dashboard similar to a given plot type by creating a dummy dataset and corresponding Python scripts.

Messages

Goal Given a kind of a plot (Dashboard, sankey etc), the objective is to generate a similar dashboard to this that tells the same story by curating a dummy/toy dataset (representing a real-world business problem) and corresponding scripts (data generation and data visualization). An input prompt must be created so that the visual found is answered by that prompt. Project Purpose Each task begins with SEARCHING the web for a reference image of a BUSINESS-RELATED dashboard or graph that matches the description you are given. Your goals are to: Come up with a business-related story the dashboard / graph you found is communicating (e.g., trends, comparisons, patterns). Write a data creation script (data_gen.py) that generates some dummy that tells the same story in the data (in .csv or .npy format). This operation should generate 2 or more data files, such as regional_sales_data.csv and regional_forecasted_data.csv, etc. Write a visualization script (viz.py) that reads your data and creates a new HTML interactive dashboard based on the inspiration that you’ve gathered from the newly found dashboard image. Find the one line code that can export this information in one line: https://plotly.com/python/interactive-html-export/#:~:text=fig.write_html(%22path/to/file.html%22) Upload all the generated and get links to submit in Labelbox [advanced capabilties] upload to bucket.ipynb Step-by-Step Workflow 1. Install Hubstaff to track your time. This is required for payment. 2. Select the Project Scatter - Python Visualization project on Hubstaff. 3. Start your Hubstaff timer, then click here to begin the project. 4. Find and Analyze the dashboard/graph you found (reference image) When you begin working on a datarow, you will be given a chart type. You will use this as a reference to determine what kind of visualization you will create. You can use Google to find a real-world visualization that you will use as a reference image. For example, you may search for something such as “dashboard for business software”. When you find an image, carefully inspect it as a guiding example. These images serve as seeds to inspire diverse, complex, and realistic data scenarios. Your objective is to creatively expand on these reference images, capturing their core features while developing datasets and visualizations that reflect real-world situations. Here are some examples of charts you should be pursuing versus not: ✅Positive examples ❌Negative examples When you find a reference image, you will need to obtain the direct URL to the image itself. You can do this by right-clicking on the image and selecting “Copy Image Address”. 5. Generate a Prompt Write a simple user-style question or instruction that the reference image would answer. This prompt frames the data story and helps guide your synthetic data generation. The prompt should not be very specific and can be open-ended. The prompt should not specify a lot of formatting requirements. The prompt must be natural and practical, reflecting the kind of questions a user might realistically ask in a real-world scenario. Here are some examples to use as inspiration only (DO NOT DIRECTLY USE THEM): Prompt topic Story & Visuals “Show how global electric-vehicle (EV) adoption has evolved since 2015 and predict the next five years.” • Multi-line time-series of unit sales by region• Stacked area of battery chemistries• Sankey of supply-chain flows🗺 Heat-map of EV market-share by country “Analyze hospital network capacity vs. infectious-disease outbreaks during winter seasons.” • Dual-axis line (ICU beds vs. cases)• Correlation heat-map of symptoms & test positivity• Box-whisker of LOS by diagnosis group “Contrast same-day vs. two-day e-commerce delivery performance during holiday peaks.” • Violin plot of delivery times• Pareto of top delay causes• Time-series forecast of warehouse backlog “Track sustainable-aviation-fuel (SAF) usage across the airline industry and project carbon savings.” • Waterfall of CO₂ reductions• Treemap of SAF feedstocks• Monte Carlo projection of carbon offset targets “Visualise smart-city energy flows between residential, commercial, and EV charging nodes.” • Chord diagram of kWh transfers• Area chart of renewables vs. grid demand🗺 Animated map of substation loads by hour “Evaluate multi-modal public-transport punctuality and rider sentiment in megacities.” • Box-plot of lateness by mode (bus, metro, rail)• Word-cloud & sentiment drill-down• Gantt of headways over 24 h “Benchmark fintech fraud-detection algorithms across geographies and transaction types.” • ROC curves for each model• Confusion-matrix heat-maps• KPI bullet charts for latency & cost “Map food-delivery fleet efficiency vs. weather impacts in dense urban zones.” • Scatter of drop-offs vs. travel km• Histogram of idle minutes per driver🗺 Isochrone map overlaying rainfall intensity “Identify semiconductor-fab yield losses and correlate with equipment maintenance logs.” • Stacked bar of defect classes• Control chart of daily yields• Network graph of tool dependencies “Forecast coastal-city real-estate risk under sea-level-rise scenarios to 2100.” • Scenario fan-chart of property values• Choropleth of flood exposure zones🗺 Animated slider of shoreline retreat 6. Generate Data to tell the business story (data_gen.py) Create a script (data_gen.py) that: Uses pandas and numpy Outputs, for example regional_sales_data.csv or regional_sales_data.npy, that follow the data presented in the dashboards. The data generation script should tell a similar story in the newly found reference/dashboard/graph image. The data should have 2 or more Data Frames or Numpys that can have enough information that could create the same dashboard. 7. Recreate the Visualization (viz.py) Write a script (viz.py) that: Reads your generated CSVs or NPYs Uses only pandas,kaleido, numpy, and plotly (library is known dash) To install plotly dash: pip install dash viz.py MUST generate ONE HTML file in the outputs folder Newly generated HTML should adhere to the style guidelines, to be a presentable business dashboard: Typography: titles MUST be bold, and properly formatted legends and labels. Layout: Well-organized legend placement, appropriate spacing. Legends: If a legend is present, ensure it is clearly displayed and boxed if appropriate. Color Palette: Use a professional and aesthetically pleasing color scheme. The color palette should complement the data and enhance readability. Overall Quality: The final plot should be polished and suitable for a presentation or publication. 8. Generate the Golden HTML Plot Run viz.py to generate an interactive chart with Plotly. Check that it works and you can interact with it properly. Export the interactive visualization to HTML using Plotly's HTML export. Render the HTML and save as golden_image.html 9. [very important to save your work] Upload Files Use the following Colab script to upload all files: [advanced capabilties] upload to bucket.ipynb NOTE: When using Colab, your folders must be in the following structure: You’ll need to manually upload these folders Folder Structure Overview <data_row_id>/ ├── data/ │ ├── sample.npy │ ├── dataframe2.csv │ └── dataframe.csv # Generated .csv and/or npy files │ ├── scripts/ │ ├── data_gen.py # Data generation script │ └── viz.py # Visualization script │ ├── outputs/ │ ├── screenshot.png # Screenshot generated using viz.py │ └── dashboard.html # Interactive html generated using viz.py fig.write_html("./name_me_something_useful.html") fig.write_image("./screenshot.png") Once uploaded, submit all the paths in the appropriate sections in the Labelbox editor. Deliverables Summary Item Description Data folder The CSV and/or NumPy data generated from data_gen.py script data_gen.py Script that generates synthetic data matching the reference data_viz.py Script that generates a plot matching the reference using the CSV Generated Plot Image Uploaded to GCS, gs://... path shared
⚙ model reasoning step
gpt-4o
⚙ model reasoning step
gpt-4o
Below is a *ready-to-copy* mini-template you can reuse for every “Scatter – Python Visualization” task. It walks through **(1) choosing & documenting a reference image, (2) crafting the business story + user prompt, (3) generating dummy data, and (4) reproducing the dashboard in Plotly/Dash**, all in the folder structure the project expects. --- ## 0 Choose & record your reference image 1. Google something like `"<chart-type> business dashboard" filetype:png` (e.g., “sankey supply-chain dashboard”). 2. Copy the *direct* image URL and paste it into a little `reference.md` you keep beside the project; that’s your traceability. 3. Stare at the image and answer: **“What single business question does this answer?”** Example: *“How did quarterly actual sales compare with forecasts in each region for FY 2024?”* --- ## 1 Craft the end-user prompt (one sentence) > **Prompt:** “Compare actual and forecast quarterly sales by region for the last fiscal year and highlight where we under- or over-performed.” Put this sentence in the Labelbox *Prompt* field. --- ## 2 `data_gen.py` – create two+ CSVs that tell the same story ```python # scripts/data_gen.py import numpy as np import pandas as pd from pathlib import Path rng = np.random.default_rng(42) OUT = Path(__file__).resolve().parents[1] / "data" OUT.mkdir(parents=True, exist_ok=True) regions = ["North America", "Europe", "Asia-Pac", "LATAM"] quarters = ["Q1", "Q2", "Q3", "Q4"] # 1️⃣ Actuals actual = pd.DataFrame( [(r, q, rng.integers(80, 140) * 1e4) # realistic spread for r in regions for q in quarters], columns=["region", "quarter", "sales_usd"] ) actual.to_csv(OUT / "regional_sales_actual.csv", index=False) # 2️⃣ Forecast # Bias forecasts slightly high/low to create a story forecast = actual.copy() forecast["forecast_usd"] = (actual["sales_usd"] * rng.normal(1.05, 0.08, len(actual))).round(0) forecast = forecast.drop(columns="sales_usd") forecast.to_csv(OUT / "regional_sales_forecast.csv", index=False) print("Data written to", OUT) ``` Feel free to add third/fourth files (e.g., YOY target, stretch-goal) if the reference dashboard needs them. --- ## 3 `viz.py` – rebuild the dashboard in Plotly/Dash ```python # scripts/viz.py import pandas as pd import plotly.graph_objects as go from pathlib import Path DATA = Path(__file__).resolve().parents[1] / "data" OUT = Path(__file__).resolve().parents[1] / "outputs" OUT.mkdir(parents=True, exist_ok=True) actual = pd.read_csv(DATA / "regional_sales_actual.csv") forecast = pd.read_csv(DATA / "regional_sales_forecast.csv") df = actual.merge(forecast, on=["region", "quarter"]) fig = go.Figure() for r in df["region"].unique(): subset = df[df.region == r] fig.add_trace(go.Bar( x=subset["quarter"], y=subset["sales_usd"], name=f"{r} Actual", legendgroup=r, offsetgroup=r )) fig.add_trace(go.Scatter( x=subset["quarter"], y=subset["forecast_usd"], mode="lines+markers", name=f"{r} Forecast", legendgroup=r, line=dict(dash="dash") )) fig.update_layout( title=dict(text="FY 2024 Sales: Actual vs Forecast by Region", font=dict(size=22, bold=True)), xaxis_title="Quarter", yaxis_title="Sales (USD)", barmode="group", legend_title_text="Legend", template="plotly_white", height=600, width=1000, margin=dict(l=60, r=30, t=80, b=60) ) # ➜ single-line HTML export fig.write_html(OUT / "dashboard.html") # Optional static thumbnail (needs kaleido) try: fig.write_image(OUT / "screenshot.png", width=1000, height=600, scale=2) except Exception as e: print("Skip screenshot –", e) print("Dashboard saved to", OUT / "dashboard.html") ``` *What this mirrors from the reference image*: * grouped bars (actual) + dashed lines (forecast) per region * clean white theme, bold title, boxed legend on the right (default), spacious margins --- ## 4 Folder layout recap ``` <data_row_id>/ ├── data/ │ ├── regional_sales_actual.csv │ └── regional_sales_forecast.csv ├── scripts/ │ ├── data_gen.py │ └── viz.py ├── outputs/ │ ├── screenshot.png │ └── dashboard.html └── reference.md (optional but handy) ``` Run: ```bash python scripts/data_gen.py python scripts/viz.py # creates outputs/dashboard.html ``` Double-check the HTML is interactive ➜ then upload the entire `<data_row_id>` folder as outlined. --- ### Adapting this template for other chart types | If reference image shows… | Tweak in `data_gen.py` | Tweak in `viz.py` | |---------------------------|------------------------|-------------------| | Sankey (e.g., supply chain) | Generate “source”, “target”, “value” columns | Use `go.Sankey` traces | | Forecast fan chart | Produce date index + multiple scenario columns | Plot multiple semi-transparent `go.Scatter` areas | | Heat-map | Wide matrix-style CSV | `go.Heatmap` | --- **Now you can iterate quickly:** pick an image ➜ note the story ➜ adjust the two scripts ➜ export ➜ upload. If you’d like me to build a different specific chart type, just drop the reference image link (or describe it) and I’ll plug it into this scaffold.
gpt-4o