文章目录
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