Skip to content

Latest commit

 

History

History
92 lines (70 loc) · 2.55 KB

File metadata and controls

92 lines (70 loc) · 2.55 KB

📊 Visualizing Sine and Cosine with Matplotlib

Want to bring trigonometry to life? With Matplotlib, you can easily plot the sine and cosine functions on the same graph, creating an intuitive visualization of their periodic nature.

📖 Table of Contents

  • 🚀 About This Project
  • 📜 Code Preview
  • 📸 Output Preview
  • 🎯 How to Run
  • 🚀 Future Improvements
  • 🤝 Contributing
  • 📜 License
  • 📩 Contact
  • 🚀 About This Project This repository contains a simple yet powerful Python script that: ✅ Plots the sine and cosine functions over a defined range ✅ Uses Matplotlib for high-quality graph rendering ✅ Highlights key aspects of wave behavior, such as phase shifts and symmetry

📜 Code Preview

import numpy as np import matplotlib.pyplot as plt

Define the range of values

x = np.linspace(0, 2 * np.pi, 100)

Compute sine and cosine values

y_sin = np.sin(x) y_cos = np.cos(x)

Create the plot

plt.figure(figsize=(8, 5)) plt.plot(x, y_sin, label="Sine", color="b") plt.plot(x, y_cos, label="Cosine", color="r")

Add labels, title, and legend

plt.xlabel("Angle (radians)") plt.ylabel("Function value") plt.title("Sine and Cosine Functions") plt.legend()

Show the plot

plt.grid() plt.show() 📸 Output Preview starting_matplotlib

🎯 How to Run Install dependencies: pip install numpy matplotlib Run the script: python plot_sine_cosine.py

📌 Enhance the visualization! Try modifying colors, line styles, or adding annotations to make your plots even more insightful.

🚀 Future Improvements 🔹 Add interactive features using plotly 🔹 Include additional trigonometric functions (e.g., tangent, cotangent) 🔹 Save the plot as an image automatically 🔹 Create an animated visualization of sine and cosine

🤝 Contributing Want to improve this project? Feel free to fork the repository and submit a pull request!

Steps to Contribute: Fork this repository 🍴 Clone your forked repo

git clone https://github.com/your-username/matplotlib_introduction.git cd sine-cosine-plot Create a new branch

git checkout -b feature-new-enhancement Make changes and commit

git add . git commit -m "Added a new feature" Push your branch and submit a pull request

git push origin feature-new-enhancement We appreciate every contribution! 🚀

📜 License This project is open-source and available under the MIT License.

📩 Contact 💬 Got questions or suggestions? Feel free to reach out: