本文整理汇总了Python中matplotlib.axes.Axes.add_artist方法的典型用法代码示例。如果您正苦于以下问题:Python Axes.add_artist方法的具体用法?Python Axes.add_artist怎么用?Python Axes.add_artist使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.axes.Axes
的用法示例。
在下文中一共展示了Axes.add_artist方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: plot_cross_cut
# 需要导入模块: from matplotlib.axes import Axes [as 别名]
# 或者: from matplotlib.axes.Axes import add_artist [as 别名]
def plot_cross_cut():
#plot cut plane with crossection of cut fibers
fig55 = figure(55)
title('Cut fibers area (ellipses)')
ax55 = Axes(fig55, [.1, .1, .8, .8])
fig55.add_axes(ax55)
for i in range(0, len(phi_x_cut)):
sy_c = sy_cut[i] + (sec - sx_cut[i]) / cos(phi_x_cut[i]) * sin(phi_x_cut[i]) * cos(theta_cut[i])
sz_c = sz_cut[i] + (sec - sx_cut[i]) / cos(phi_x_cut[i]) * sin(phi_x_cut[i]) * sin(theta_cut[i])
if (0 < phi_x_cut[i] < arctan((fib.lf) / fib.df)) and (sx_cut[i] - fib.lf / 2. * cos(phi_x_cut[i]) + fib.df / 2. * sin(phi_x_cut[i]) < sec < sx_cut[i] + fib.lf / 2. * cos(phi_x_cut[i]) - fib.df / 2. * sin(phi_x_cut[i])):
patch = Ellipse([ sy_c, sz_c ] , fib.df, fib.df / cos(phi_x_cut[i]), theta_cut[i] * 180 / pi , color = 'black')
ax55.add_artist(patch)
ax55.set_xlim(-spec.l_y / 2., spec.l_y / 2.)
ax55.set_ylim(-spec.l_z / 2., spec.l_z / 2.)
示例2: add_artist
# 需要导入模块: from matplotlib.axes import Axes [as 别名]
# 或者: from matplotlib.axes.Axes import add_artist [as 别名]
def add_artist(self, a, path_interpolation=None):
'''
Modified :meth:`matplotlib.axes.Axes.add_artist`. Enables the
interpolation of a given artist, e.g. a line or rectangle
Keyword arguments:
*a*:
Artist to be added
Accepts: :class:`matplotlib.artist.Artist` instance
*path_interpolation`:
if set, the path of the artist will be interpolated with the
given value. If set to 0, bezier arcs are used to connect.
'''
if path_interpolation is not None:
if hasattr(a, "get_path"):
a.get_path()._interpolation_steps = path_interpolation
else:
raise AttributeError("Artist has no Path")
return Axes.add_artist(self, a)
示例3: plot_station_positions
# 需要导入模块: from matplotlib.axes import Axes [as 别名]
# 或者: from matplotlib.axes.Axes import add_artist [as 别名]
def plot_station_positions(directions_file_path: Path, stations: list, ax: Axes, grid_config: GridConfig=default_domains.bc_mh_044,
save_upstream_boundaries_to_shp=False):
with Dataset(str(directions_file_path)) as ds:
flow_dirs = ds.variables["flow_direction_value"][:]
flow_acc_area = ds.variables["accumulation_area"][:]
lons_2d, lats_2d = [ds.variables[k][:] for k in ["lon", "lat"]]
basemap, reg_of_interest = grid_config.get_basemap_using_shape_with_polygons_of_interest(lons_2d, lats_2d,
shp_path=default_domains.MH_BASINS_PATH,
resolution="i")
cell_manager = CellManager(flow_dirs, lons2d=lons_2d, lats2d=lats_2d, accumulation_area_km2=flow_acc_area)
station_to_model_point = cell_manager.get_model_points_for_stations(station_list=stations, nneighbours=8)
#####
xx, yy = basemap(lons_2d, lats_2d)
upstream_edges = cell_manager.get_upstream_polygons_for_points(
model_point_list=list(station_to_model_point.values()), xx=xx, yy=yy)
upstream_edges_latlon = cell_manager.get_upstream_polygons_for_points(
model_point_list=list(station_to_model_point.values()), xx=lons_2d, yy=lats_2d)
plot_utils.draw_upstream_area_bounds(ax, upstream_edges=upstream_edges, color="r", linewidth=0.6)
if save_upstream_boundaries_to_shp:
plot_utils.save_to_shape_file(upstream_edges_latlon, folder_path="mh/engage_report/upstream_stations_areas/mh_{}".format(grid_config.dx), in_proj=None)
basemap.drawrivers(linewidth=0.2)
basemap.drawstates(linewidth=0.1)
basemap.drawcountries(linewidth=0.1)
basemap.drawcoastlines(linewidth=0.2)
pos_ids, lons_pos, lats_pos = [], [], []
pos_labels = []
legend_lines = []
for i, (s, mp) in enumerate(sorted(station_to_model_point.items(), key=lambda p: p[0].latitude, reverse=True), start=1):
pos_ids.append(s.id)
pos_labels.append(i)
lons_pos.append(mp.longitude)
lats_pos.append(mp.latitude)
legend_lines.append("{}: {}".format(i, s.id))
xm, ym = basemap(lons_pos, lats_pos)
ax.scatter(xm, ym, c="g", s=20)
for txt, x1, y1, pos_label in zip(pos_ids, xm, ym, pos_labels):
ax.annotate(pos_label, xy=(x1, y1))
at = AnchoredText("\n".join(legend_lines), prop=dict(size=8), frameon=True, loc=1)
at.patch.set_boxstyle("round,pad=0.,rounding_size=0.2")
ax.add_artist(at)