
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Increase Colormap Linewidth Quality in Streamplot Matplotlib
To increase colormap/linewidth quality in streamplot matplotlib, we can take the following steps
Steps
Set the figure size and adjust the padding between and around the subplots.
Create a figure and a set of subplots.
Create x and y data points and then use np.meshgrid() to return the coordinate matrices from the coordinate vectors.
Find X and Y using x and y data points.
Create a streamplot with x, y, X and Y data points. You can increase the linewidth using the linewidth parameter in the method. Here we have used linewidth=5.
Create a colorbar for a ScalarMappable instance, *stream.lines*.
To display the figure, use Show() method.
Example
import numpy as np from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True fig, ax = plt.subplots() x, y = np.meshgrid(np.linspace(-5, 5, 20), np.linspace(-5, 5, 20)) X = y Y = 3 * x - 4 * y stream = ax.streamplot(x, y, X, Y, density=1, linewidth=5, cmap='plasma', color=Y) fig.colorbar(stream.lines, ax=ax) plt.show()
Output
It will produce the following output −
Advertisements