quadratic-plotter/README.md
anas-rashid 4f262ab4c1 Remove screenshot section from README
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
2026-04-03 21:25:58 +02:00

116 lines
2.8 KiB
Markdown

# Quadratic Equation Plotter
A Python GUI application for plotting quadratic equations using Tkinter and Matplotlib.
## Features
- Plot any quadratic equation in the form: **y = ax² + bx + c**
- Adjustable X-axis range
- Visualize vertex and roots (when they exist)
- Save plots in multiple formats (PNG, JPEG, PDF, SVG)
- Interactive matplotlib navigation toolbar (zoom, pan, save)
- Clean, user-friendly interface
## Requirements
- Python 3.6 or higher
- NumPy
- Matplotlib
## Installation
1. Install Python dependencies:
```bash
pip install -r requirements.txt
```
Or install manually:
```bash
pip install numpy matplotlib
```
## Usage
Run the application:
```bash
python quadratic_plotter.py
```
### Interface Components:
1. **Coefficients Input**:
- Enter values for `a`, `b`, and `c`
- Default: a=1, b=0, c=0 (plots y = x²)
2. **X-axis Range**:
- Set the range of x-values to plot
- Default: -10 to 10
3. **Buttons**:
- **Plot Quadratic**: Generate the plot with current parameters
- **Save Plot**: Save the current plot to a file
- **Clear Plot**: Clear the current plot
4. **Plot Area**:
- Interactive matplotlib plot with zoom and pan capabilities
- Vertex shown as red dot (for a ≠ 0)
- Roots shown as green dots (when real roots exist)
- Legend showing equation and key points
## Example Plots
1. **Standard Parabola**: a=1, b=0, c=0
2. **Shifted Parabola**: a=1, b=-2, c=1
3. **Downward Parabola**: a=-1, b=0, c=4
4. **Linear Function**: a=0, b=2, c=1 (plots a straight line)
## Features in Detail
### Vertex Calculation
The vertex of the parabola is calculated using:
```
x_vertex = -b / (2a)
y_vertex = a(x_vertex)² + b(x_vertex) + c
```
### Roots Calculation
Real roots are calculated using the quadratic formula:
```
x = [-b ± √(b² - 4ac)] / (2a)
```
### Plot Customization
- Blue line: Quadratic curve
- Red dot: Vertex of parabola
- Green dots: Real roots (x-intercepts)
- Grid lines for easy reference
- Axes lines through origin
## Error Handling
The application includes error handling for:
- Invalid numeric input
- X-min greater than X-max
- File save errors
- Missing dependencies
## License
This project is open source and available for educational and personal use.
## Troubleshooting
If you encounter issues:
1. **Missing dependencies**: Ensure all packages are installed
2. **GUI not showing**: Check if Tkinter is installed (usually bundled with Python)
3. **Plot not updating**: Verify all input fields contain valid numbers
4. **ImportError: "NavigationToolbar2Tk" is not exported**: This application includes compatibility code for different matplotlib versions. If you see this error, update matplotlib to version 3.4 or later:
```bash
pip install --upgrade matplotlib
```
The code will automatically try multiple import locations for backward compatibility.