Does anyone know how to change the line width of one line depending on x in matplotlib? For example, how would you make a thin line for small x values ββand a thickness for large x values?
Basically, you need to use a polygon instead of a string. As a short example:
import numpy as np import matplotlib.pyplot as plt # Make the original line... x = np.linspace(0, 10, 100) y = 2 * x thickness = 0.5 * np.abs(np.sin(x) * np.cos(x)) plt.fill_between(x, y - thickness, y + thickness, color='blue') plt.show()
Or, if you need something closer to your description:
import numpy as np import matplotlib.pyplot as plt # Make the original line... x = np.linspace(0, 10, 100) y = np.cos(x) thickness = 0.01 * x plt.fill_between(x, y - thickness, y + thickness, color='blue') plt.show()
Source: https://habr.com/ru/post/901734/More articles:Run model creation code in Django - djangoHow to avoid name conflicts in a modular Python system? - pythonError update page: value cannot be null (value set: null) TAAL [BLAME_file] - commentsRename an existing file before replacing it in the Inno setup - inno-setupIs there a better option for GroupBy for a dictionary (or solution) for a statement? - dictionarywhat does 0X mean? - javascriptChanging a column name without re-creating the MySQL table - mysqlwhere does 0x come from? - historyDirectional graph with maximum vertex accuracy - algorithmHow to configure logging in Spring.NET using log4net? - spring.netAll Articles