43 lines
1.3 KiB
Plaintext
43 lines
1.3 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"\n# Exercise 5\n\nExercise 5 with matplotlib.\n"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {
|
|
"collapsed": false
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"import numpy as np\nimport matplotlib.pyplot as plt\n\nplt.figure(figsize=(8, 5), dpi=80)\nplt.subplot(111)\n\nX = np.linspace(-np.pi, np.pi, 256)\nS = np.sin(X)\nC = np.cos(X)\n\nplt.plot(X, C, color=\"blue\", linewidth=2.5, linestyle=\"-\")\nplt.plot(X, S, color=\"red\", linewidth=2.5, linestyle=\"-\")\n\nplt.xlim(X.min() * 1.1, X.max() * 1.1)\nplt.xticks([-np.pi, -np.pi / 2, 0, np.pi / 2, np.pi])\n\nplt.ylim(C.min() * 1.1, C.max() * 1.1)\nplt.yticks([-1, 0, +1])\n\nplt.show()"
|
|
]
|
|
}
|
|
],
|
|
"metadata": {
|
|
"kernelspec": {
|
|
"display_name": "Python 3",
|
|
"language": "python",
|
|
"name": "python3"
|
|
},
|
|
"language_info": {
|
|
"codemirror_mode": {
|
|
"name": "ipython",
|
|
"version": 3
|
|
},
|
|
"file_extension": ".py",
|
|
"mimetype": "text/x-python",
|
|
"name": "python",
|
|
"nbconvert_exporter": "python",
|
|
"pygments_lexer": "ipython3",
|
|
"version": "3.12.11"
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 0
|
|
} |