# 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()

matplotlib学习之散点图与条形图的更多相关文章

  1. Matplotlib学习笔记(一)

    原   matplotlib学习笔记 参考:Python数据科学入门教程 Python3.6.1 jupyter notebook .caret, .dropup > .btn > .ca ...

  2. Matplotlib学习---matplotlib的一些基本用法

    Matplotlib有两种接口,一种是matlab风格接口,一种是面向对象接口.在这里,统一使用面向对象接口.因为面向对象接口可以适应更复杂的场景,在多图之间进行切换将变得非常容易. 首先导入matp ...

  3. matplotlib 学习总结

    matplotlib 学习总结 作者:csj更新时间:01.09 email:59888745@qq.com 说明:因内容较多,会不断更新 xxx学习总结: 回主目录:2017 年学习记录和总结 # ...

  4. Matplotlib学习笔记(二)

    原  Matplotlib学习笔记 参考:Python数据科学入门教程 Python3.6.1 jupyter notebook .caret, .dropup > .btn > .car ...

  5. Matplotlib学习---用matplotlib画箱线图(boxplot)

    箱线图通过数据的四分位数来展示数据的分布情况.例如:数据的中心位置,数据间的离散程度,是否有异常值等. 把数据从小到大进行排列并等分成四份,第一分位数(Q1),第二分位数(Q2)和第三分位数(Q3)分 ...

  6. Matplotlib学习---用matplotlib画直方图/密度图(histogram, density plot)

    直方图用于展示数据的分布情况,x轴是一个连续变量,y轴是该变量的频次. 下面利用Nathan Yau所著的<鲜活的数据:数据可视化指南>一书中的数据,学习画图. 数据地址:http://d ...

  7. Matplotlib学习---用matplotlib画散点图,气泡图(scatter plot, bubble chart)

    Matplotlib里有两种画散点图的方法,一种是用ax.plot画,一种是用ax.scatter画. 一. 用ax.plot画 ax.plot(x,y,marker="o",co ...

  8. matplotlib常见绘图基础代码小结:折线图、散点图、条形图、直方图、饼图

    一.折线图 二.散点图 三.条形图 四.直方图 五.饼图 一.折线图折线图用于显示随时间或有序类别的变化趋势 from matplotlib import pyplot as plt x = rang ...

  9. Matplotlib散点图、条形图、直方图-02

    对比常用统计图 折线图: 特点:能够显示数据的变化趋势,反映事物的变化情况.(变化) 直方图: 特点:绘制连续性的数据,展示一组或者多组数据的分布情况(统计) 条形图: 特点:绘制离散的数据,能够一眼 ...

随机推荐

  1. 小米开源文件管理器MiCodeFileExplorer-源码研究(6)-媒体文件MediaFile和文件类型MimeUtils

    接着之前的第4篇,本篇的2个类,仍然是工具类.MediaFile,媒体文件,定义了一大堆的常量,真正的有用的方法就几个.isAudioFileType.isVideoFileType之类的. Mime ...

  2. C#引用c++DLL结构体数组注意事项(数据发送与接收时)

    本文转载自:http://blog.csdn.net/lhs198541/article/details/7593045 最近做的项目,需要在C# 中调用C++ 写的DLL,因为C# 默认的编码方式是 ...

  3. CODEVS——T2744 养鱼喂妹纸

    http://codevs.cn/problem/2744/ 时间限制: 1 s  空间限制: 64000 KB 题目等级 : 钻石 Diamond 题解  查看运行结果     题目描述 Descr ...

  4. 安装 VNC 和 XRDP

    安装 VNC 和 XRDPapt-get install vnc4server tightvncserver xrdp fluxbox xtermcat >vncstop.sh << ...

  5. 根证书 CA

    根证书 CA 密钥没有密码,使用下面的指令添加密码 openssl rsa -aes256 -in cakey_nopw.pem -out cakey_pw.pem cacert.pem -----B ...

  6. C# 异步延时执行

    https://blog.csdn.net/xiawu1990/article/details/78350253?utm_source=blogxgwz7 var t = Task.Run(async ...

  7. php的数据类型和变量的作用域

    1)php支持例如以下所看到的的基本数据类型: Integer(整数).Float(浮点数).String(字符串).Boolean(布尔值).Array(数组).Object(对象),此外还有两个特 ...

  8. 26.SpringBoot事务注解详解

    转自:https://www.cnblogs.com/kesimin/p/9546225.html @Transactional spring 事务注解 1.简单开启事务管理 @EnableTrans ...

  9. Docker安装RabbitMQ,RabbitMQ Management使用

    原文:Docker安装RabbitMQ,RabbitMQ Management使用 版权声明:本文为博主原创文章,未经博主允许不得转载.需要转载请先评论或者邮箱联系我,谢谢! https://blog ...

  10. 原生js大总结十

    91.ajax的优点     a.提高运行效率   b.提高用户体验,让多件事情同时发生   c.在不刷新页面的情况下可以对局部数据进行加载和刷新       92.ajax请求的流程   1.创建通 ...