有可能用seaborn绘制断轴图吗? [英] Is it possible to draw a broken axis graph with seaborn?

查看:44
本文介绍了有可能用seaborn绘制断轴图吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用现有数据绘制一个破碎的x轴图形(例如下面的图形),我的问题是是否可以使用

解决方案

虽然不像我想要的那么漂亮,但是可以.

 %matplotlib内联#如果您正在Jupyter Notebook中运行它.将seaborn导入为sns将numpy导入为np导入matplotlib.pyplot作为pltx = np.linspace(0,20,500)y = np.sin(x)f,(ax1,ax2)= plt.subplots(ncols = 2,nrows = 1,sharey = True)斧= sns.tsplot(时间= x,数据= y,斧= ax1)斧= sns.tsplot(时间= x,数据= y,斧= ax2)ax1.set_xlim(0,6.5)ax2.set_xlim(13.5,20) 

I need to draw a broken x axis graph (e.g. the graph below) with existing data, my question is whether it's possible to use seaborn APIs to do that?

解决方案

Not as pretty as I'd like but works.

%matplotlib inline  # If you are running this in a Jupyter Notebook.
import seaborn as sns
import numpy as np
import matplotlib.pyplot as plt


x = np.linspace(0, 20, 500)
y = np.sin(x)

f, (ax1, ax2) = plt.subplots(ncols=2, nrows=1, sharey=True)
ax = sns.tsplot(time=x, data=y, ax=ax1)
ax = sns.tsplot(time=x, data=y, ax=ax2)

ax1.set_xlim(0, 6.5)
ax2.set_xlim(13.5, 20)

这篇关于有可能用seaborn绘制断轴图吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆