Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upload #6

Merged
merged 2 commits into from
Jul 26, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add files via upload
  • Loading branch information
YasmineLiu committed Jul 25, 2023
commit f467699e88b969031cf1148e7cb5e0db411cb567
29 changes: 29 additions & 0 deletions 0 Collection/LineCollection.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.collections import LineCollection
#绘制50条线
N = 50
x = np.arange(N)
ys = [x + i for i in x] # Many sets of y to plot vs. x
segs = [np.column_stack([x, y]) for y in ys]

fig, ax = plt.subplots()
ax.set_xlim(np.min(x), np.max(x))
ax.set_ylim(np.min(ys), np.max(ys))

colors = plt.rcParams['axes.prop_cycle'].by_key()['color']

line_segments = LineCollection(segs,
array=x,
linewidths=(0.5, 1, 1.5, 2,4,6),#设置线条宽度
colors=colors,#设置颜色
linestyles='dashed',#设置线条为短虚线
# antialiaseds=False,#抗锯齿关闭
)
ax.add_collection(line_segments)
# 这段决定colorbar
# axcb = fig.colorbar(line_segments)
# axcb.set_label('Line Number')
ax.set_title('Line Collection with mapped colors')
plt.sci(line_segments) # This allows interactive changing of the colormap.
plt.show()