Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
add road sign#26360
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Closed
Uh oh!
There was an error while loading.Please reload this page.
Closed
add road sign#26360
Changes fromall commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
45 changes: 45 additions & 0 deletionsadd_road_sign/main.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
from matplotlib.path import Path | ||
import matplotlib.pyplot as plt | ||
def custom_box_style(x0, y0, width, height, mutation_size): | ||
""" | ||
Given the location and size of the box, return the path of the box around | ||
it. Rotation is automatically taken care of. | ||
Parameters | ||
---------- | ||
x0, y0, width, height : float | ||
Box location and size. | ||
mutation_size : float | ||
Mutation reference scale, typically the text font size. | ||
""" | ||
# padding | ||
mypad = 0.3 | ||
pad = mutation_size * mypad | ||
# width and height with padding added. | ||
width = width + 2 * pad | ||
height = height + 2 * pad | ||
# boundary of the padded box | ||
x0, y0 = x0 - pad, y0 - pad | ||
x1, y1 = x0 + width, y0 + height | ||
# return the new path | ||
return Path([(x0, y0), (x1, y0), (x1, y1), (x0, y1), | ||
(x0-pad, (y0+y1)/2), (x0, y0), (x0, y0)], | ||
closed=True) | ||
#设置一号参数 | ||
fig, ax = plt.subplots(figsize=(3, 3)) | ||
ax.text(0.5, 0.5, "Test", size=30, va="center", ha="center", rotation=30, | ||
bbox=dict(boxstyle=custom_box_style, alpha=0.2)) | ||
#设置二号参数 | ||
fig, ax = plt.subplots(figsize=(5, 5)) | ||
t = ax.text(0.5, 0.5, "Direction", | ||
ha="center", va="center", rotation=45, size=15, | ||
bbox=dict(boxstyle="rarrow,pad=0.3", | ||
fc="lightblue", ec="steelblue", lw=2)) | ||
# 显示图像 | ||
plt.show() | ||
24 changes: 24 additions & 0 deletionsadd_road_sign/scratch_2.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import matplotlib.pyplot as plt | ||
import numpy as np | ||
fig, ax = plt.subplots(figsize=(3, 3)) | ||
ann = ax.annotate("Test", | ||
xy=(0.2, 0.2), xycoords='data', | ||
xytext=(0.8, 0.8), textcoords='data', | ||
size=20, va="center", ha="center", | ||
bbox=dict(boxstyle="round4", fc="w"), | ||
arrowprops=dict(arrowstyle="fancy", | ||
connectionstyle="arc3,rad=0.2", | ||
relpos=(0., 0.), | ||
fc="w")) | ||
ann = ax.annotate("Test", | ||
xy=(0.2, 0.2), xycoords='data', | ||
xytext=(0.8, 0.8), textcoords='data', | ||
size=20, va="center", ha="center", | ||
bbox=dict(boxstyle="round4", fc="w"), | ||
arrowprops=dict(arrowstyle="fancy", | ||
connectionstyle="arc3,rad=-0.2", | ||
relpos=(1., 0.), | ||
fc="w")) | ||
plt.show() |
32 changes: 32 additions & 0 deletionsadd_road_sign/solve.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import matplotlib.pyplot as plt | ||
from matplotlib.patches import Arrow | ||
# 创建一个图形对象和子图 | ||
fig, ax = plt.subplots() | ||
# 设置字体大小和颜色 | ||
font_size = 25 | ||
font_color = 'yellow' | ||
# 设置背景颜色 | ||
background_color = 'green' | ||
# 绘制箭头路标,设置填充颜色和边框颜色 | ||
arrow = Arrow(0.2, 0.2, 0.6, 0.6, width=0.5, edgecolor='yellow', facecolor='red', linewidth=3) | ||
ax.add_patch(arrow) | ||
# 添加注释文本,设置字体大小和颜色 | ||
ax.text(0.5, 0.9, 'RIGHT', ha='center', va='center', fontsize=font_size, color=font_color) | ||
# 设置图像范围 | ||
ax.set_xlim(0, 1) | ||
ax.set_ylim(0, 1) | ||
# 设置整个图形对象的背景颜色 | ||
fig.patch.set_facecolor(background_color) | ||
# 隐藏坐标轴 | ||
ax.axis('off') | ||
# 显示图像 | ||
plt.show() |
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.