如何使用Seaborn绘制阶跃函数?

时间:2018-07-25 07:50:54

标签: python seaborn

我想使用类似于matplotlib example

的Seaborn绘制阶梯图
import seaborn as sns
x = [1,2,3,4]
y = [0.002871, 0.0051, 0.0086, 0.005]
sns.lineplot(x,y)

我可以使用drawstyle='steps-post'吗?

以下内容无效:sns.lineplot(x,y, drawstyle='steps-pre')

结果应如下所示: step plot

1 个答案:

答案 0 :(得分:1)

由于- hosts: dbserver tasks: - name: "Debian | Install Mysql Client package" apt: name: "{{ item }}" state: present with_items: - mysql-client - python3-dev - libmysqlclient-dev - python3-mysqldb when: - zabbix_server_database == 'mysql' tags: - zabbix-server - init - database - name: "MySQL | Create database and import file >= 3.0" mysql_db: name: "{{ zabbix_server_dbname }}" encoding: "{{ zabbix_server_dbencoding }}" collation: "{{ zabbix_server_dbcollation }}" state: import target: "{{ ls_output_create.stdout }}" when: - zabbix_version is version_compare('3.0', '>=') - zabbix_database_sqlload - not done_file.stat.exists tags: - zabbix-server - database 的其他关键字参数已传递到matplotlib的plot函数,因此您可以直接使用sns.lineplot参数。以下代码在seaborn 0.9.0和matplotlib 2.2.2中可以正常工作。

drawstyle

enter image description here

或类似地与import matplotlib.pyplot as plt import seaborn as sns x = [1,2,3,4] y = [0.002871, 0.0051, 0.0086, 0.005] sns.lineplot(x,y, drawstyle='steps-pre') plt.show()

enter image description here