# **Plotter Module**
A Python module to generate plots from a CSV configuration file using `seaborn`. This module allows you to create custom plots by reading plot configurations directly from a CSV file and automatically generating the plots according to the specified settings.
## Features
- **CSV-driven Plot Generation**: Read plot configurations from a CSV file and generate plots accordingly.
- **Customizable Plot Settings**: Control plot features such as axis labels, titles, themes, color palettes, and more.
- **Multiple Plot Sizes**: Choose from predefined aspect ratios (`small`, `medium`, `big`, `wide`).
- **Save Plots**: Optionally save plots as PNG, SVG, or PDF with custom resolutions.
- **Flexible Theme**: Select from light or dark themes.
- **Seaborn-powered**: Built on top of `seaborn`, making it easy to work with beautiful, statistical plots.
## Installation
To use this module, you need Python 3.x and the following libraries:
- `seaborn`
- `matplotlib`
- `pandas`
### Install via pip:
```bash
pip install seaborn matplotlib pandas
```
## Usage
### 1. **Importing the Module**:
```python
from plotter import Plotter
import pandas as pd
```
### 2. **Prepare Your Data**:
Ensure you have a `DataFrame` ready with the data to plot. For example:
```python
data = pd.DataFrame({
'time': [1, 2, 3, 4, 5],
'value': [10, 20, 15, 30, 25],
'category': ['A', 'B', 'A', 'B', 'A']
})
```
### 3. **Prepare Your Configuration CSV File**:
Create a CSV file (`plot_config.csv`) with the following columns (or your own as needed):
| x_var | y_var | x_label | y_label | hue | style | size | theme | palette | aspect | xlim | ylim | title |
|-------|-------|---------|---------|------|-------|------|-------|---------|--------|------|------|-------|
| time | value | Time | Value | category | | | light | deep | wide | 0,35 | 0,40 | Sample Plot 1 |
| time | value | Time | Value | category | | | dark | pastel | small | 0,40 | 0,50 | Sample Plot 2 |
### 4. **Generate Plots from CSV**:
Call the `plot_from_csv` function to read the configuration and generate plots:
```python
plotter = Plotter(data)
plotter.plot_from_csv('plot_config.csv', data, save_folder="plots")
```
### Parameters:
- **csv_file**: Path to the CSV file containing plot configurations.
- **data**: DataFrame containing the data to plot.
- **save_folder** (optional): Folder where the plots will be saved. If not specified, plots will be shown without saving.
- **dpi** (optional): Resolution for saving plots (default is 300).
### 5. **Plot Customization**:
You can customize the plot appearance in the CSV:
- **x_var** and **y_var**: Column names for the X and Y axes.
- **x_label** and **y_label**: Labels for the X and Y axes.
- **hue**: Variable to use for color encoding.
- **style**: Variable to use for line style.
- **size**: Variable to use for size encoding.
- **theme**: Select between `'light'` or `'dark'` for plot background theme.
- **palette**: Choose color palette (e.g., `'deep'`, `'pastel'`, `'muted'`).
- **aspect**: Set plot aspect ratio (`'small'`, `'medium'`, `'big'`, `'wide'`).
- **xlim** and **ylim**: Set axis limits as tuples.
- **title**: Add a title to the plot.
### 6. **Example Code**:
```python
import pandas as pd
from plotter import Plotter
# Sample Data
data = pd.DataFrame({
'time': [1, 2, 3, 4, 5],
'value': [10, 20, 15, 30, 25],
'category': ['A', 'B', 'A', 'B', 'A']
})
# Create the Plotter instance
plotter = Plotter(data)
# Plot the configurations from the CSV file
plotter.plot_from_csv('plot_config.csv', data, save_folder="plots")
```
### 7. **Saving the Plot**:
If you specify a folder in `save_folder`, the plots will be saved with the name `plot_1.png`, `plot_2.png`, etc. You can also specify custom file formats (e.g., PNG, SVG) and DPI.
## Example CSV (`plot_config.csv`):
```csv
x_var,y_var,x_label,y_label,hue,style,size,theme,palette,aspect,xlim,ylim,title
time,value,Time,Value,category,,medium,light,deep,wide,0,35,Sample Plot 1
time,value,Time,Value,category,,big,dark,pastel,small,0,40,Sample Plot 2
```
## Advanced Usage
You can extend the `Plotter` class to include more specific functionalities such as:
- Tooltips or zooming features (for future versions).
- Error handling for missing data or invalid configurations.
---
### Contributing
Feel free to open issues, create pull requests, or suggest improvements. This module is open for contributions and enhancements.
---
### License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
---
You can modify and expand this template as your project evolves! It should give users a clear guide on how to get started with your module.
Raw data
{
"_id": null,
"home_page": "https://github.com/pedrohenriquecoimbra/csvplotter",
"name": "csvplotter",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "csv, plot, figure, image, graph, data",
"author": "Pedro Henrique Coimbra",
"author_email": "pedro-henrique.herig-coimbra@inrae.fr",
"download_url": "https://files.pythonhosted.org/packages/e9/2a/574055021cc698e50577fc9702b6fa44d1d5d62b1e9938ce27cc849de308/csvplotter-0.0.6.4.1.tar.gz",
"platform": "any",
"description": "# **Plotter Module**\n\nA Python module to generate plots from a CSV configuration file using `seaborn`. This module allows you to create custom plots by reading plot configurations directly from a CSV file and automatically generating the plots according to the specified settings.\n\n## Features\n- **CSV-driven Plot Generation**: Read plot configurations from a CSV file and generate plots accordingly.\n- **Customizable Plot Settings**: Control plot features such as axis labels, titles, themes, color palettes, and more.\n- **Multiple Plot Sizes**: Choose from predefined aspect ratios (`small`, `medium`, `big`, `wide`).\n- **Save Plots**: Optionally save plots as PNG, SVG, or PDF with custom resolutions.\n- **Flexible Theme**: Select from light or dark themes.\n- **Seaborn-powered**: Built on top of `seaborn`, making it easy to work with beautiful, statistical plots.\n\n## Installation\n\nTo use this module, you need Python 3.x and the following libraries:\n- `seaborn`\n- `matplotlib`\n- `pandas`\n\n### Install via pip:\n\n```bash\npip install seaborn matplotlib pandas\n```\n\n## Usage\n\n### 1. **Importing the Module**:\n\n```python\nfrom plotter import Plotter\nimport pandas as pd\n```\n\n### 2. **Prepare Your Data**:\nEnsure you have a `DataFrame` ready with the data to plot. For example:\n\n```python\ndata = pd.DataFrame({\n 'time': [1, 2, 3, 4, 5],\n 'value': [10, 20, 15, 30, 25],\n 'category': ['A', 'B', 'A', 'B', 'A']\n})\n```\n\n### 3. **Prepare Your Configuration CSV File**:\n\nCreate a CSV file (`plot_config.csv`) with the following columns (or your own as needed):\n\n| x_var | y_var | x_label | y_label | hue | style | size | theme | palette | aspect | xlim | ylim | title |\n|-------|-------|---------|---------|------|-------|------|-------|---------|--------|------|------|-------|\n| time | value | Time | Value | category | | | light | deep | wide | 0,35 | 0,40 | Sample Plot 1 |\n| time | value | Time | Value | category | | | dark | pastel | small | 0,40 | 0,50 | Sample Plot 2 |\n\n### 4. **Generate Plots from CSV**:\n\nCall the `plot_from_csv` function to read the configuration and generate plots:\n\n```python\nplotter = Plotter(data)\nplotter.plot_from_csv('plot_config.csv', data, save_folder=\"plots\")\n```\n\n### Parameters:\n- **csv_file**: Path to the CSV file containing plot configurations.\n- **data**: DataFrame containing the data to plot.\n- **save_folder** (optional): Folder where the plots will be saved. If not specified, plots will be shown without saving.\n- **dpi** (optional): Resolution for saving plots (default is 300).\n\n### 5. **Plot Customization**:\nYou can customize the plot appearance in the CSV:\n- **x_var** and **y_var**: Column names for the X and Y axes.\n- **x_label** and **y_label**: Labels for the X and Y axes.\n- **hue**: Variable to use for color encoding.\n- **style**: Variable to use for line style.\n- **size**: Variable to use for size encoding.\n- **theme**: Select between `'light'` or `'dark'` for plot background theme.\n- **palette**: Choose color palette (e.g., `'deep'`, `'pastel'`, `'muted'`).\n- **aspect**: Set plot aspect ratio (`'small'`, `'medium'`, `'big'`, `'wide'`).\n- **xlim** and **ylim**: Set axis limits as tuples.\n- **title**: Add a title to the plot.\n\n### 6. **Example Code**:\n\n```python\nimport pandas as pd\nfrom plotter import Plotter\n\n# Sample Data\ndata = pd.DataFrame({\n 'time': [1, 2, 3, 4, 5],\n 'value': [10, 20, 15, 30, 25],\n 'category': ['A', 'B', 'A', 'B', 'A']\n})\n\n# Create the Plotter instance\nplotter = Plotter(data)\n\n# Plot the configurations from the CSV file\nplotter.plot_from_csv('plot_config.csv', data, save_folder=\"plots\")\n```\n\n### 7. **Saving the Plot**:\nIf you specify a folder in `save_folder`, the plots will be saved with the name `plot_1.png`, `plot_2.png`, etc. You can also specify custom file formats (e.g., PNG, SVG) and DPI.\n\n## Example CSV (`plot_config.csv`):\n\n```csv\nx_var,y_var,x_label,y_label,hue,style,size,theme,palette,aspect,xlim,ylim,title\ntime,value,Time,Value,category,,medium,light,deep,wide,0,35,Sample Plot 1\ntime,value,Time,Value,category,,big,dark,pastel,small,0,40,Sample Plot 2\n```\n\n## Advanced Usage\n\nYou can extend the `Plotter` class to include more specific functionalities such as:\n- Tooltips or zooming features (for future versions).\n- Error handling for missing data or invalid configurations.\n\n---\n\n### Contributing\n\nFeel free to open issues, create pull requests, or suggest improvements. This module is open for contributions and enhancements.\n\n---\n\n### License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n---\n\nYou can modify and expand this template as your project evolves! It should give users a clear guide on how to get started with your module.\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Plotter using .csv filesWritten by pedrohenriquecoimbra",
"version": "0.0.6.4.1",
"project_urls": {
"Homepage": "https://github.com/pedrohenriquecoimbra/csvplotter"
},
"split_keywords": [
"csv",
" plot",
" figure",
" image",
" graph",
" data"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "61910a2a9debf8c326e545818e2e2e92fbf7f3a43f42ac71aeb828692048a937",
"md5": "21776c95e0d26e0eb60e166d8a477f49",
"sha256": "d916df90aa98414b264eb3c9ac41b92cf6dd1b0147bb97715850220fef4bfdfd"
},
"downloads": -1,
"filename": "csvplotter-0.0.6.4.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "21776c95e0d26e0eb60e166d8a477f49",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 13726,
"upload_time": "2025-02-21T16:34:24",
"upload_time_iso_8601": "2025-02-21T16:34:24.059988Z",
"url": "https://files.pythonhosted.org/packages/61/91/0a2a9debf8c326e545818e2e2e92fbf7f3a43f42ac71aeb828692048a937/csvplotter-0.0.6.4.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "e92a574055021cc698e50577fc9702b6fa44d1d5d62b1e9938ce27cc849de308",
"md5": "dac3adb4db55cf0ea95ae54a00252d8c",
"sha256": "a49203aa523d0daa34cbd87fbe5a1c15393b36fac091c71a61ce80c546d49888"
},
"downloads": -1,
"filename": "csvplotter-0.0.6.4.1.tar.gz",
"has_sig": false,
"md5_digest": "dac3adb4db55cf0ea95ae54a00252d8c",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 11417,
"upload_time": "2025-02-21T16:34:26",
"upload_time_iso_8601": "2025-02-21T16:34:26.025816Z",
"url": "https://files.pythonhosted.org/packages/e9/2a/574055021cc698e50577fc9702b6fa44d1d5d62b1e9938ce27cc849de308/csvplotter-0.0.6.4.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-02-21 16:34:26",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "pedrohenriquecoimbra",
"github_project": "csvplotter",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "csvplotter"
}