Matplotlib inverse vector using the vector drawing and an exponential function

Matplotlib programming

import numpy as np
import matplotlib.pyplot as plt

a = b = np.arange(0, 3, 0.1)
c = np.exp(a)
d = c[::-1]

fig, ax = plt.subplots()
ax.plot(a, c, 'k--', label='Model length')
ax.plot(a, d, 'k:', label='Data length')
ax.plot(a, c + d, 'k', label='Total message length')

legend = ax.legend(loc='upper center', shadow=True, fontsize='x-large')

legend.get_frame().set_facecolor('#00FFCC')

plt.show()

Python grammar explanations

c[::-1]Means: taking the element from the front (opposite to) the
d = c[::-1] will of the elements of the vector c taken backwards, but the index is not less than 0, it is practically equivalent to that of FIG storage index vector function values read upside down , and then presents the results in the figure.

Finished map

Here Insert Picture Description

Published 515 original articles · won praise 1014 · Views 210,000 +

Guess you like

Origin blog.csdn.net/weixin_43896318/article/details/104332982