# coding:utf-8
from matplotlib import pyplot as plt
import numpy as np plt.style.use('ggplot') x = np.random.randn(200)
y = x + np.random.randn(200) * 0.5 # 确定图的位置
margin_border = 0.1
width = 0.6
margin_between = 0.02
height = 0.2 left_s = margin_border
bottom_s = margin_border
height_s = width
width_s = width left_x = margin_border
bottom_x = margin_border + width + margin_between
height_x = height
width_x = width left_y = margin_border + width + margin_between
bottom_y = margin_border
height_y = width
width_y = height plt.figure(1, figsize=(8, 8))
rect_s = [left_s, bottom_s, width_s, height_s]
rect_x = [left_x, bottom_x, width_x, height_x]
rect_y = [left_y, bottom_y, width_y, height_y] axScatter = plt.axes(rect_s)
axHisX = plt.axes(rect_x)
axHisY = plt.axes(rect_y) axHisX.set_xticks([])
axHisY.set_yticks([]) # 绘图
axScatter.scatter(x, y) bin_width = 0.25
xymax = np.max([np.max(np.fabs(x)), np.max(np.fabs(y))])
lim = int(xymax / bin_width + 1) * bin_width axScatter.set_xlim(-lim, lim)
axScatter.set_ylim(-lim, lim) bins = np.arange(-lim, lim + bin_width, bin_width) axHisX.hist(x, bins=bins)
axHisY.hist(y, bins=bins, orientation='horizontal') # 同步条形图与散点图的横纵坐标
axHisX.set_xlim(axScatter.get_xlim())
axHisY.set_ylim(axScatter.get_ylim()) plt.show()

最新文章

  1. java图书管理的一个小模块(增删改查,不使用数据库)
  2. 内存只有4G的MBP要怎么破
  3. 智能家居常用WiFi模块
  4. java12 - 7 排序的案例
  5. [笔记] MySql Workbench 导出表结构和数据报错 mysqldump: [ERROR] unknown variable 'delayed-insert=FALSE'
  6. const和#define的区别
  7. thinkphp学习资料
  8. java之Set源代码浅析
  9. delphi程序设计之底层原理(有些深度)
  10. Java课程设计-定时器
  11. Linux显示指定区块大小为1024字节
  12. Docker教程:dokcer的配置和命令
  13. Magic Pen 6
  14. byte数组和int之间相互转化的方法
  15. ffmpeg 在ubuntu上编译环境搭建和开发
  16. [c/c++] programming之路(6)、ASCII码,数据类型、随机数、字符转换及拼接等
  17. java串口编程
  18. 洛谷P3209平面图判定 [HNOI2010] 2-sat
  19. ln软连接
  20. [leetcode]Populating Next Right Pointers in Each Node @ Python

热门文章

  1. HDU 2191 悼念512汶川大地震
  2. PatentTips - Improving security in a virtual machine host
  3. Swift视频教程,Swift千人学iOS开发编程语言
  4. 优化HTML代码的多种技巧
  5. c# 查询sql 返回多个參数
  6. ellipsize-TextView省略号的设定
  7. startActivityForResult()的用法
  8. 非阻塞键盘检测getchar()
  9. IK分词器插件elasticsearch-analysis-ik 6.1.1
  10. POJ Fence Repair(优先队列)