Compare commits
3 Commits
6a86badaea
...
731062d3c6
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
731062d3c6 | ||
|
|
1166790801 | ||
|
|
658d49bd00 |
67
inst/z1.txt
67
inst/z1.txt
@ -1,5 +1,68 @@
|
||||
Napisz program w języku Python, który narysuje wykres funkcji liniowej y=x.
|
||||
Programming Challenges - Increasing Difficulty
|
||||
|
||||
Author: AI
|
||||
Task 1: Basic Plotting
|
||||
Create a Python script that plots a simple quadratic function y = x^2 for x values from -5 to 5.
|
||||
Requirements:
|
||||
- Use NumPy to generate the x values (at least 100 points)
|
||||
- Calculate corresponding y values
|
||||
- Plot the function using Matplotlib
|
||||
- Add appropriate labels and title
|
||||
|
||||
Task 2: Multiple Functions
|
||||
Extend your script to plot two functions on the same graph:
|
||||
- y1 = sin(x)
|
||||
- y2 = cos(x)
|
||||
Requirements:
|
||||
- Plot both functions for x values from 0 to 4π
|
||||
- Use different colors for each function
|
||||
- Add a legend to distinguish the functions
|
||||
- Include axis labels and a title
|
||||
|
||||
Task 3: Parametric Plotting
|
||||
Create a script that plots a parametric curve (e.g., a spiral or Lissajous figure).
|
||||
Requirements:
|
||||
- Use parametric equations to generate x and y coordinates
|
||||
- Plot the curve with appropriate styling
|
||||
- Add labels, title, and grid
|
||||
- Experiment with different parameter ranges
|
||||
|
||||
Task 4: Data Visualization
|
||||
Create a script that visualizes a dataset (you can generate synthetic data or use built-in datasets).
|
||||
Requirements:
|
||||
- Create at least 2 different types of plots (e.g., line plot, scatter plot, bar chart)
|
||||
- Include proper labels, titles, and legends
|
||||
- Use color effectively to enhance understanding
|
||||
- Add annotations or special markers for important data points
|
||||
|
||||
Task 5: Interactive Plotting
|
||||
Create an interactive plot where users can modify parameters and see the results in real-time.
|
||||
Requirements:
|
||||
- Use matplotlib widgets or another interactive library
|
||||
- Allow users to change at least 2 parameters of a function
|
||||
- Update the plot dynamically as parameters change
|
||||
- Include clear instructions for the user
|
||||
|
||||
Task 6: Advanced Visualization
|
||||
Create a comprehensive visualization that combines multiple plot types in subplots.
|
||||
Requirements:
|
||||
- Create at least 3 subplots with different types of visualizations
|
||||
- Share axes where appropriate
|
||||
- Use consistent styling across all subplots
|
||||
- Include a main title for the entire figure
|
||||
- Save the figure to a file with high resolution
|
||||
|
||||
Task 7: Object-Oriented Plotting
|
||||
Refactor one of your previous scripts to use object-oriented Matplotlib approach.
|
||||
Requirements:
|
||||
- Use Figure and Axes objects explicitly
|
||||
- Create reusable plotting functions or classes
|
||||
- Implement proper error handling
|
||||
- Document your code with comments or docstrings
|
||||
|
||||
Task 8: Custom Visualization
|
||||
Create a unique visualization of your choice that demonstrates advanced Matplotlib features.
|
||||
Requirements:
|
||||
- Use advanced features like custom colormaps, 3D plotting, or animations
|
||||
- Include data analysis or transformation
|
||||
- Make the visualization informative and visually appealing
|
||||
- Provide a clear explanation of what the visualization shows
|
||||
|
||||
9
roz/1.py
9
roz/1.py
@ -10,6 +10,13 @@ y = x
|
||||
# Narysuj wykres
|
||||
plt.plot(x, y, label='y = x')
|
||||
|
||||
# Dodaj okrąg
|
||||
theta = np.linspace(0, 2*np.pi, 400)
|
||||
radius = 5
|
||||
x_circle = radius * np.cos(theta)
|
||||
y_circle = radius * np.sin(theta)
|
||||
plt.plot(x_circle, y_circle, label=f'Okrąg o promieniu {radius}')
|
||||
|
||||
# Dodaj siatkę
|
||||
plt.grid(True)
|
||||
|
||||
@ -18,7 +25,7 @@ plt.xlabel('x')
|
||||
plt.ylabel('y')
|
||||
|
||||
# Dodaj tytuł
|
||||
plt.title('Wykres funkcji liniowej y = x')
|
||||
plt.title('Wykres funkcji liniowej y = x z okręgiem')
|
||||
|
||||
# Pokaż legendę
|
||||
plt.legend()
|
||||
|
||||
28
rozw
Normal file
28
rozw
Normal file
@ -0,0 +1,28 @@
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
# Generate x values from 0 to 4π
|
||||
x = np.linspace(0, 4*np.pi, 1000)
|
||||
|
||||
# Calculate y values for both functions
|
||||
y1 = np.sin(x)
|
||||
y2 = np.cos(x)
|
||||
|
||||
# Create the plot
|
||||
plt.figure(figsize=(10, 6))
|
||||
plt.plot(x, y1, color='blue', label='sin(x)')
|
||||
plt.plot(x, y2, color='red', label='cos(x)')
|
||||
|
||||
# Add labels and title
|
||||
plt.xlabel('x')
|
||||
plt.ylabel('y')
|
||||
plt.title('Sine and Cosine Functions')
|
||||
|
||||
# Add legend
|
||||
plt.legend()
|
||||
|
||||
# Add grid for better readability
|
||||
plt.grid(True, alpha=0.3)
|
||||
|
||||
# Display the plot
|
||||
plt.show()
|
||||
Loading…
Reference in New Issue
Block a user