522个matplotlib绘图案例,包含:折线图、散点图、条形图、饼图、直方图、3D图等,源码可直接运行!

matplotlib介绍

Matplotlib是一个广泛使用的Python绘图库,可以用于生成各种类型的图表和可视化。它提供了丰富的功能和灵活的接口,使用户可以轻松地创建精美的图表。下面将介绍一些常见的Matplotlib图表类型。

图表介绍

折线图(Line Plot)

折线图是Matplotlib中最常见的图表类型之一。它用于显示数据随时间或其他连续变量的变化趋势。通过plot()函数可以绘制折线图,并可以根据需要添加标题、坐标轴标签和图例等。

散点图(Scatter Plot)

散点图用于显示两个变量之间的关系。通过scatter()函数可以绘制散点图,并可以根据需要设置点的大小、颜色和形状等。

条形图(Bar Plot)

条形图用于比较不同类别之间的数值。通过bar()函数可以绘制条形图,并可以根据需要调整条形的宽度、颜色和排列方式等。

饼图(Pie Chart)

饼图用于显示不同类别占总体的比例。通过pie()函数可以绘制饼图,并可以根据需要设置饼图的颜色、标签和偏移等。

直方图(Histogram)

直方图用于显示连续变量的分布情况。通过hist()函数可以绘制直方图,并可以根据需要设置分箱数和颜色等。

箱线图(Box Plot)

箱线图用于显示数据的分布和离群值。通过boxplot()函数可以绘制箱线图,并可以根据需要设置箱体的颜色、线条的样式和离群值的显示方式等。

热力图(Heatmap)

热力图用于显示两个变量之间的相关性。通过imshow()函数可以绘制热力图,并可以根据需要设置颜色映射和标签等。

3D图(3D Plot)

Matplotlib还支持绘制3D图形,如散点图、曲面图和等高线图等。通过plot_surface()、plot_wireframe()contour()等函数可以绘制各种类型的3D图形。

除了上述常见的图表类型,Matplotlib还提供了许多其他类型的图表,如极坐标图、雷达图和地图等。此外,Matplotlib还支持自定义图表的样式和布局,使用户可以根据需要进行个性化的设计。

总之,Matplotlib是一个功能强大且灵活的绘图库,可以满足各种数据可视化的需求。通过掌握不同类型的图表和相应的绘图函数,用户可以轻松地创建出具有吸引力和信息量的图表。无论是在数据分析、科学研究还是数据可视化领域,Matplotlib都是一个不可或缺的工具。

源码文件

共计522个绘图python文件以及522个jupyter文件,全部可直接运行!

1.  animated_histogram.py
2.  animate_decay.py
3.  animation_demo.py
4.  bayes_update.py
5.  double_pendulum.py
6.  dynamic_image.py
7.  frame_grabbing_sgskip.py
8.  multiple_axes.py
9.  pause_resume.py
10.  rain.py
11.  random_walk.py
12.  simple_anim.py
13.  simple_scatter.py
14.  strip_chart.py
15.  unchained.py
16.  demo_anchored_direction_arrows.py
17.  demo_axes_divider.py
18.  demo_axes_grid.py
19.  demo_axes_grid2.py
20.  demo_axes_hbox_divider.py
21.  demo_axes_rgb.py
22.  demo_colorbar_of_inset_axes.py
23.  demo_colorbar_with_axes_divider.py
24.  demo_colorbar_with_inset_locator.py
25.  demo_edge_colorbar.py
26.  demo_fixed_size_axes.py
27.  demo_imagegrid_aspect.py
28.  inset_locator_demo.py
29.  inset_locator_demo2.py
30.  make_room_for_ylabel_using_axesgrid.py
31.  parasite_simple.py
32.  parasite_simple2.py
33.  scatter_hist_locatable_axes.py
34.  simple_anchored_artists.py
35.  simple_axesgrid.py
36.  simple_axesgrid2.py
37.  simple_axes_divider1.py
38.  simple_axes_divider3.py
39.  simple_axisline4.py
40.  simple_colorbar.py
41.  axis_direction.py
42.  demo_axisline_style.py
43.  demo_axis_direction.py
44.  demo_curvelinear_grid.py
45.  demo_curvelinear_grid2.py
46.  demo_floating_axes.py
47.  demo_floating_axis.py
48.  demo_parasite_axes.py
49.  demo_parasite_axes2.py
50.  demo_ticklabel_alignment.py
51.  demo_ticklabel_direction.py
52.  simple_axisartist1.py
53.  simple_axisline.py
54.  simple_axisline3.py
55.  simple_axis_direction01.py
56.  simple_axis_direction03.py
57.  simple_axis_pad.py
58.  colorbar_basics.py
59.  colormap_reference.py
60.  color_by_yvalue.py
61.  color_cycle_default.py
62.  color_demo.py
63.  custom_cmap.py
64.  named_colors.py
65.  close_event.py
66.  coords_demo.py
67.  cursor_demo.py
68.  data_browser.py
69.  figure_axes_enter_leave.py
70.  ginput_manual_clabel_sgskip.py
71.  image_slices_viewer.py
72.  keypress_demo.py
73.  lasso_demo.py
74.  legend_picking.py
75.  looking_glass.py
76.  path_editor.py
77.  pick_event_demo.py
78.  pick_event_demo2.py
79.  poly_editor.py
80.  pong_sgskip.py
81.  resample.py
82.  timers.py
83.  trifinder_event_demo.py
84.  viewlims.py
85.  zoom_window.py
86.  affine_image.py
87.  barb_demo.py
88.  barcode_demo.py
89.  colormap_interactive_adjustment.py
90.  colormap_normalizations.py
91.  colormap_normalizations_symlognorm.py
92.  contourf_demo.py
93.  contourf_hatching.py
94.  contourf_log.py
95.  contours_in_optimization_demo.py
96.  contour_corner_mask.py
97.  contour_demo.py
98.  contour_image.py
99.  contour_label_demo.py
100.  demo_bboximage.py
101.  figimage_demo.py
102.  image_annotated_heatmap.py
103.  image_antialiasing.py
104.  image_clip_path.py
105.  image_demo.py
106.  image_masked.py
107.  image_nonuniform.py
108.  image_transparency_blend.py
109.  image_zcoord.py
110.  interpolation_methods.py
111.  irregulardatagrid.py
112.  layer_images.py
113.  matshow.py
114.  multi_image.py
115.  pcolormesh_grids.py
116.  pcolormesh_levels.py
117.  pcolor_demo.py
118.  plot_streamplot.py
119.  quadmesh_demo.py
120.  quiver_demo.py
121.  quiver_simple_demo.py
122.  shading_example.py
123.  specgram_demo.py
124.  spy_demos.py
125.  tricontour_demo.py
126.  tricontour_smooth_delaunay.py
127.  tricontour_smooth_user.py
128.  trigradient_demo.py
129.  triinterp_demo.py
130.  tripcolor_demo.py
131.  triplot_demo.py
132.  watermark_image.py
133.  barchart.py
134.  barh.py
135.  bar_colors.py
136.  bar_label_demo.py
137.  bar_stacked.py
138.  broken_barh.py
139.  capstyle.py
140.  categorical_variables.py
141.  cohere.py
142.  csd_demo.py
143.  curve_error_band.py
144.  errorbar_limits_simple.py
145.  errorbar_subsample.py
146.  eventcollection_demo.py
147.  eventplot_demo.py
148.  fill.py
149.  filled_step.py
150.  fill_betweenx_demo.py
151.  fill_between_alpha.py
152.  fill_between_demo.py
153.  gradient_bar.py
154.  hat_graph.py
155.  horizontal_barchart_distribution.py
156.  joinstyle.py
157.  linestyles.py
158.  lines_with_ticks_demo.py
159.  line_demo_dash_control.py
160.  marker_reference.py
161.  markevery_demo.py
162.  masked_demo.py
163.  multicolored_line.py
164.  multivariate_marker_plot.py
165.  psd_demo.py
166.  scatter_custom_symbol.py
167.  scatter_demo2.py
168.  scatter_hist.py
169.  scatter_masked.py
170.  scatter_star_poly.py
171.  scatter_with_legend.py
172.  simple_plot.py
173.  span_regions.py
174.  spectrum_demo.py
175.  stackplot_demo.py
176.  stairs_demo.py
177.  stem_plot.py
178.  step_demo.py
179.  timeline.py
180.  vline_hline_demo.py
181.  xcorr_acorr_demo.py
182.  anchored_artists.py
183.  bbox_intersect.py
184.  contour_manual.py
185.  coords_report.py
186.  customize_rc.py
187.  custom_projection.py
188.  demo_agg_filter.py
189.  demo_ribbon_box.py
190.  fig_x.py
191.  fill_spiral.py
192.  findobj_demo.py
193.  font_indexing.py
194.  ftface_props.py
195.  histogram_path.py
196.  hyperlinks_sgskip.py
197.  image_thumbnail_sgskip.py
198.  keyword_plotting.py
199.  logos2.py
200.  multipage_pdf.py
201.  multiprocess_sgskip.py
202.  packed_bubbles.py
203.  patheffect_demo.py
204.  print_stdout_sgskip.py
205.  rasterization_demo.py
206.  set_and_get.py
207.  svg_filter_line.py
208.  svg_filter_pie.py
209.  table_demo.py
210.  tickedstroke_demo.py
211.  transoffset.py
212.  zorder_demo.py
213.  2dcollections3d.py
214.  3d_bars.py
215.  bars3d.py
216.  box3d.py
217.  contour3d.py
218.  contour3d_2.py
219.  contour3d_3.py
220.  contourf3d.py
221.  contourf3d_2.py
222.  custom_shaded_3d_surface.py
223.  errorbar3d.py
224.  hist3d.py
225.  lines3d.py
226.  lorenz_attractor.py
227.  mixed_subplots.py
228.  offset.py
229.  pathpatch3d.py
230.  polys3d.py
231.  projections.py
232.  quiver3d.py
233.  rotate_axes3d_sgskip.py
234.  scatter3d.py
235.  stem3d_demo.py
236.  subplot3d.py
237.  surface3d.py
238.  surface3d_2.py
239.  surface3d_3.py
240.  surface3d_radial.py
241.  text3d.py
242.  tricontour3d.py
243.  tricontourf3d.py
244.  trisurf3d.py
245.  trisurf3d_2.py
246.  view_planes_3d.py
247.  voxels.py
248.  voxels_numpy_logo.py
249.  voxels_rgb.py
250.  voxels_torus.py
251.  wire3d.py
252.  wire3d_animation_sgskip.py
253.  wire3d_zero_stride.py
254.  bar_of_pie.py
255.  nested_pie.py
256.  pie_and_donut_labels.py
257.  pie_demo2.py
258.  pie_features.py
259.  polar_bar.py
260.  polar_demo.py
261.  polar_error_caps.py
262.  polar_legend.py
263.  polar_scatter.py
264.  axline.py
265.  pyplot_simple.py
266.  pyplot_text.py
267.  pyplot_three.py
268.  pyplot_two_subplots.py
269.  asinh_demo.py
270.  aspect_loglog.py
271.  custom_scale.py
272.  logit_demo.py
273.  log_bar.py
274.  log_demo.py
275.  power_norm.py
276.  scales.py
277.  semilogx_demo.py
278.  symlog_demo.py
279.  arrow_guide.py
280.  artist_reference.py
281.  collections.py
282.  compound_path.py
283.  dolphin.py
284.  donut.py
285.  ellipse_collection.py
286.  ellipse_demo.py
287.  fancybox_demo.py
288.  hatch_demo.py
289.  hatch_style_reference.py
290.  line_collection.py
291.  patch_collection.py
292.  path_patch.py
293.  quad_bezier.py
294.  scatter.py
295.  anatomy.py
296.  firefox.py
297.  integral.py
298.  mandelbrot.py
299.  stock_prices.py
300.  xkcd.py
301.  advanced_hillshading.py
302.  anscombe.py
303.  hinton_demo.py
304.  leftventricle_bullseye.py
305.  mri_demo.py
306.  mri_with_eeg.py
307.  radar_chart.py
308.  sankey_basics.py
309.  sankey_links.py
310.  sankey_rankine.py
311.  skewt.py
312.  topographic_hillshading.py
313.  centered_spines_with_arrows.py
314.  multiple_yaxis_with_spines.py
315.  spines.py
316.  spines_dropped.py
317.  spine_placement_demo.py
318.  barchart_demo.py
319.  boxplot.py
320.  boxplot_color.py
321.  boxplot_demo.py
322.  boxplot_vs_violin.py
323.  bxp.py
324.  confidence_ellipse.py
325.  customized_violin.py
326.  errorbar.py
327.  errorbars_and_boxes.py
328.  errorbar_features.py
329.  errorbar_limits.py
330.  hexbin_demo.py
331.  hist.py
332.  histogram_cumulative.py
333.  histogram_features.py
334.  histogram_histtypes.py
335.  histogram_multihist.py
336.  multiple_histograms_side_by_side.py
337.  time_series_histogram.py
338.  violinplot.py
339.  bmh.py
340.  dark_background.py
341.  fivethirtyeight.py
342.  ggplot.py
343.  grayscale.py
344.  plot_solarizedlight2.py
345.  style_sheets_reference.py
346.  align_labels_demo.py
347.  auto_subplots_adjust.py
348.  axes_box_aspect.py
349.  axes_demo.py
350.  axes_margins.py
351.  axes_props.py
352.  axes_zoom_effect.py
353.  axhspan_demo.py
354.  axis_equal_demo.py
355.  axis_labels_demo.py
356.  broken_axis.py
357.  colorbar_placement.py
358.  custom_figure_class.py
359.  demo_constrained_layout.py
360.  demo_tight_layout.py
361.  fahrenheit_celsius_scales.py
362.  figure_size_units.py
363.  figure_title.py
364.  ganged_plots.py
365.  geo_demo.py
366.  gridspec_and_subplots.py
367.  gridspec_multicolumn.py
368.  gridspec_nested.py
369.  invert_axes.py
370.  mosaic.py
371.  multiple_figs_demo.py
372.  secondary_axis.py
373.  shared_axis_demo.py
374.  share_axis_lims_views.py
375.  subfigures.py
376.  subplot.py
377.  subplots_adjust.py
378.  subplots_demo.py
379.  two_scales.py
380.  zoom_inset_axes.py
381.  accented_text.py
382.  align_ylabels.py
383.  angles_on_bracket_arrows.py
384.  angle_annotation.py
385.  annotate_transform.py
386.  annotation_basic.py
387.  annotation_demo.py
388.  annotation_polar.py
389.  arrow_demo.py
390.  autowrap.py
391.  custom_legends.py
392.  date.py
393.  demo_annotation_box.py
394.  demo_text_path.py
395.  demo_text_rotation_mode.py
396.  dfrac_demo.py
397.  engineering_formatter.py
398.  fancyarrow_demo.py
399.  fancytextbox_demo.py
400.  figlegend_demo.py
401.  fonts_demo.py
402.  fonts_demo_kw.py
403.  font_family_rc.py
404.  font_file.py
405.  font_table.py
406.  label_subplots.py
407.  legend.py
408.  legend_demo.py
409.  line_with_text.py
410.  mathtext_asarray.py
411.  mathtext_demo.py
412.  mathtext_examples.py
413.  mathtext_fontfamily_example.py
414.  multiline.py
415.  placing_text_boxes.py
416.  rainbow_text.py
417.  stix_fonts_demo.py
418.  text_alignment.py
419.  text_commands.py
420.  text_fontdict.py
421.  text_rotation_relative_to_line.py
422.  tex_demo.py
423.  titles_demo.py
424.  unicode_minus.py
425.  usetex_baseline_test.py
426.  usetex_fonteffects.py
427.  watermark_text.py
428.  auto_ticks.py
429.  centered_ticklabels.py
430.  colorbar_tick_labelling_demo.py
431.  custom_ticker1.py
432.  date_concise_formatter.py
433.  date_demo_convert.py
434.  date_demo_rrule.py
435.  date_formatters_locators.py
436.  date_index_formatter.py
437.  date_precision_and_epochs.py
438.  dollar_ticks.py
439.  fig_axes_customize_simple.py
440.  major_minor_demo.py
441.  scalarformatter.py
442.  tick-formatters.py
443.  tick-locators.py
444.  ticklabels_rotation.py
445.  ticks_too_many.py
446.  tick_labels_from_values.py
447.  tick_label_right.py
448.  tick_xlabel_top.py
449.  annotate_with_units.py
450.  artist_tests.py
451.  bar_demo2.py
452.  bar_unit_demo.py
453.  basic_units.py
454.  ellipse_with_units.py
455.  evans_test.py
456.  radian_demo.py
457.  units_sample.py
458.  units_scatter.py
459.  anchored_box04.py
460.  annotate_explain.py
461.  annotate_simple01.py
462.  annotate_simple02.py
463.  annotate_simple03.py
464.  annotate_simple04.py
465.  annotate_simple_coord01.py
466.  annotate_simple_coord02.py
467.  annotate_simple_coord03.py
468.  annotate_text_arrow.py
469.  connectionstyle_demo.py
470.  connect_simple01.py
471.  custom_boxstyle01.py
472.  demo_gridspec01.py
473.  demo_gridspec03.py
474.  demo_gridspec06.py
475.  pgf_fonts.py
476.  pgf_preamble_sgskip.py
477.  pgf_texsystem.py
478.  simple_annotate01.py
479.  simple_legend01.py
480.  simple_legend02.py
481.  canvasagg.py
482.  embedding_in_gtk3_panzoom_sgskip.py
483.  embedding_in_gtk3_sgskip.py
484.  embedding_in_gtk4_panzoom_sgskip.py
485.  embedding_in_gtk4_sgskip.py
486.  embedding_in_qt_sgskip.py
487.  embedding_in_tk_sgskip.py
488.  embedding_in_wx2_sgskip.py
489.  embedding_in_wx3_sgskip.py
490.  embedding_in_wx4_sgskip.py
491.  embedding_in_wx5_sgskip.py
492.  embedding_webagg_sgskip.py
493.  fourier_demo_wx_sgskip.py
494.  gtk3_spreadsheet_sgskip.py
495.  gtk4_spreadsheet_sgskip.py
496.  mathtext_wx_sgskip.py
497.  mplcvd.py
498.  mpl_with_glade3_sgskip.py
499.  pylab_with_gtk3_sgskip.py
500.  pylab_with_gtk4_sgskip.py
501.  svg_histogram_sgskip.py
502.  svg_tooltip_sgskip.py
503.  toolmanager_sgskip.py
504.  web_application_server_sgskip.py
505.  wxcursor_demo_sgskip.py
506.  annotated_cursor.py
507.  buttons.py
508.  check_buttons.py
509.  cursor.py
510.  lasso_selector_demo_sgskip.py
511.  menu.py
512.  mouse_cursor.py
513.  multicursor.py
514.  polygon_selector_demo.py
515.  polygon_selector_simple.py
516.  radio_buttons.py
517.  range_slider.py
518.  rectangle_selector.py
519.  slider_demo.py
520.  slider_snap_demo.py
521.  span_selector.py
522.  textbox.py

源码地址

链接:https://pan.baidu.com/s/1MXBSvP3e07aqgYN6tQhamg?pwd=fqre

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
### 回答1: Matplotlib是一个Python数据可视化库,提供了丰富的绘图接口和常用形,包括: 1. 折线图(Line Plot):用于展示数据随时间或其他连续变量的变化趋势。 2. 散点图(Scatter Plot):用于展示两个变量之间的关系,可以用不同颜色或大小的点表示不同的数据。 3. 条形图(Bar Plot):用于比较不同类别之间的数值大小。 4. 直方图(Histogram):用于展示数据的分布情况,可以看出数据的中心趋势和离散程度。 5. 饼图(Pie Chart):用于展示不同类别之间的占比情况。 6. 箱线(Box Plot):用于展示数据的分布情况和异常值。 7. 热力(Heatmap):用于展示数据的相关性和趋势,可以用不同颜色的方块表示不同的数值。 8. 3D3D Plot):用于展示三维数据的分布情况和趋势。 以上是Matplotlib常用的形,可以根据不同的需求选择合适的形进行数据可视化。 ### 回答2: Matplotlib是一个Python数据可视化库,它提供了非常丰富的数据可视化功能。Matplotlib提供了一个包含各种绘图类的模块matplotlib.pyplot,它是一个有状态的可视化系统,具有面向对象的绘图接口。 Matplotlib接口主要包含以下几个部分: 1.形容器:Figure和Axes Figure是整个绘图区域的容器,用来管理和存储绘制出来的所有形元素,每个Figure对象可以包含多个Axes对象,每个Axes对象都是一张表。 2.形组件:坐标轴、标题、文本、标签等 Matplotlib提供了丰富的形组件,包括坐标轴、标题、文本、标签等,可以通过修改这些组件的属性来实现各种样式的形。 3.绘图方法:bar、scatter、hist等 Matplotlib提供了丰富的绘图方法,包括条形图散点图直方图等,可以用来展示数据的不同方面或特点。 常用的形类型包括: 1.条形图 条形图是目前最流行的一种可视化方式,它可以显示多组数据之间的比较关系,可以提供直观的数据分析方法。条形图通常用于显示分类数据。 2.散点图 散点图可以很好地展示关于两个变量之间的关系和它们是否有相关性。散点图可以将两个变量绘制到平面坐标系上,展示变量之间的关联程度。 3.折线图 折线图可以展示数据的趋势和变化,通常用于显示时间序列数据。它是一种连续数据可视化的方法,将数据点连接起来,形成一个平滑的曲线。 4.直方图 直方图可以很好地展示数据的分布情况,通常将数据按照范围划分为若干等分片段,统计每个片段内的数据数量,并绘制成柱状。 总之,Matplotlib提供了非常丰富的数据可视化功能,可以满足各种各样的数据可视化需求,以展示数据的不同侧面和特性。 ### 回答3: Matplotlib是Python科学计算中最常用的绘图库之一,因为它提供了广泛的绘图能力,包括二维和三维形,直方图散点图、等高线、误差条3D形等等。同时,Matplotlib非常灵活,用户可以根据自己的需要定制形。 Matplotlib接口主要包括pyplot模块和OO模块。pyplot模块提供了和Matlab类似的绘图接口,它是Matplotlib中最常用的模块,因为它提供了一系列的命令式函数,能够快速地对数据进行可视化。而OO模块则更加面向对象,用户可以通过创建Figure、Axes和Axis对象来控制每个元素的细节。 在Matplotlib中,最常用的形包括: 1.线性:线性最常见的用途是用来展示趋势和关系。在Matplotlib中,可以使用plot()函数绘制线性,可以设置线条的类型、颜色和标签等。 2.散点图散点图用于展示两个变量之间的关系,通常用来发现数据中的异常值或者找出数据之间的相关性。Matplotlib中可以使用scatter()函数绘制散点图,可以设置散点的大小、颜色和形状等。 3.条形图条形图用于比较不同类别的数据之间的差异,通常使用垂直或水平的条形来表示不同类别的数据。在Matplotlib中,可以使用bar()函数绘制条形图,可以设置条形的宽度、颜色和标签等。 4.饼图饼图用于展示不同类别的数据之间的比例关系,通常使用饼形来表示不同数据之间的比例。在Matplotlib中,可以使用pie()函数绘制饼图,可以设置饼图的颜色、标签和半径等。 5.箱线:箱线用于展示数据的分布情况,通常使用盒子来表示数据的上下四分位数,使用线来表示数据的中位数和极值。在Matplotlib中,可以使用boxplot()函数绘制箱线,可以设置盒子的宽度、颜色和标签等。 除了上述形,Matplotlib还提供了许多其他的形类型,用户可以根据自己的需要选择适合的形类型来展示数据。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

帅帅的Python

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值