A Python project for generating high-quality scientific plots with custom data points and labels. This interactive tool allows users to input their own data and customize plot labels through a command-line interface.
This project creates matplotlib-based visualizations from user-provided data points. The program prompts users for x and y coordinates, axis labels, and a plot title, making it versatile for various data visualization needs.
- Interactive Input: User-friendly command-line interface for data entry
- Flexible Plotting: Create plots with any numerical data series
- Interactive Display: Uses Qt5Agg backend for interactive plot windows
- High-Quality Output: Saves plots as high-resolution PNG images (300 DPI)
- Grid Display: Enhanced readability with grid lines
- Custom Labels: Full control over axis labels and plot title
- Automatic Saving: Plots are automatically saved to the
images/directory
- Python 3.12 or higher
- A GUI environment (for interactive plotting)
- Git (for version control)
- matplotlib >= 3.10.6
- PyQt5 >= 5.15.11
Choose one of the following installation methods:
# Clone the repository
git clone https://github.com/Kneysh/plot-graph.git
# Navigate to project directory
cd plot-graph
# Install dependencies using uv
uv sync# Clone the repository
git clone https://github.com/Kneysh/plot-graph.git
# Navigate to project directory
cd plot-graph
# Create and activate virtual environment (recommended)
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install matplotlib>=3.10.6 pyqt5>=5.15.11-
Ensure you're in the project directory:
cd plot-graph -
Run the script:
python main.py
-
The program will:
- Display an interactive plot window
- Save the plot as
images/plot.png - Show a confirmation message
When running the program, you'll be prompted to enter:
- X-axis values: Enter comma-separated numbers (e.g.,
1,2,3,4,5) - Y-axis values: Enter comma-separated numbers (e.g.,
10,20,30,40,50) - X-axis label: Enter a descriptive label for your x-axis
- Y-axis label: Enter a descriptive label for your y-axis
- Plot title: Enter the title for your plot
Example input:
Please Enter your data points:
x : 1,2,3,4,5
y : 10,20,30,40,50
Enter label for X axis: Time (seconds)
Enter label for Y axis: Temperature (°C)
Enter the Title of the graph: Temperature vs TimeThe program will:
- Generate an interactive plot window showing your data
- Save the plot as a high-resolution PNG file (300 DPI)
- Display a confirmation message
The generated plot includes:
- Data points marked with circular markers
- Lines connecting the data points
- A grid for better readability
- Your custom axis labels and title
- Automatically scaled axes based on your data
To modify the plot appearance, you can edit the plot function in main.py:
def plot(x:list, y:list, x_label:str, y_label:str, title:str):
# Modify marker style, color, or size
plt.plot(x, y, marker='o') # Try 's' for squares, '^' for triangles
# Adjust grid style
plt.grid(True) # Add alpha=0.5 for transparency
# Change output settings
plt.savefig('./images/plot.png', dpi=300, bbox_inches='tight')
```## Contribution Guidelines
We welcome contributions! Here's how you can help improve this project:
### 1. Setting Up Development Environment
```bash
# Fork the repository on GitHub
# Clone your fork
git clone https://github.com/YOUR-USERNAME/plot-graph.git
# Add upstream remote
git remote add upstream https://github.com/Kneysh/plot-graph.git
# Create a new branch
git checkout -b feature/your-feature-name-
Code Style
- Follow PEP 8 guidelines
- Use meaningful variable names
- Add comments for complex logic
- Include docstrings for functions
-
Testing
- Test your changes with different data sets
- Verify plot generation works
- Check interactive features
- Ensure proper error handling
-
Committing Changes
git add . git commit -m "Brief description of changes" git push origin feature/your-feature-name
-
Update your fork:
git fetch upstream git rebase upstream/main
-
Create a pull request:
- Go to GitHub and create a PR from your feature branch
- Provide a clear description of changes
- Include screenshots if UI changes were made
- Reference any related issues
- All PRs will be reviewed
- Address any requested changes
- Maintain clear communication in PR comments
- Be patient during the review process
-
Display Issues
- Error: "No display name and no $DISPLAY environment variable"
# Solution: Set matplotlib to use a non-interactive backend export MPLBACKEND="Agg"
-
Dependencies
- Qt5 missing:
# Ubuntu/Debian sudo apt-get install python3-qt5 # macOS brew install pyqt5
-
Permission Issues
# Fix images directory permissions chmod 755 images/
plot-graph/
├── main.py # Main plotting script with interactive input
├── pyproject.toml # Project configuration and dependencies
├── README.md # Documentation
└── images/ # Output directory for generated plots
└── plot.png # Your generated plot
This project is released under the MIT License. See LICENSE file for details.
- Create an issue for bug reports
- Start a discussion for feature requests
- Check existing issues before reporting
For more information, contact the maintainers or open an issue on GitHub.
