有没有办法在matplotlib中只有部分子图之间共享Y轴?

时间:2016-03-04 22:56:40

标签: python matplotlib

我有N个子图,我想为除了其中一个之外的所有人共享Y轴。有可能吗?

1 个答案:

答案 0 :(得分:4)

是的,您可以指定哪些suplots共享哪个轴与哪个轴(这不是拼写错误,我的意思是这句话)。 <?php $user = 'root'; $pass = ''; $db = 'uopuser'; $con=mysqli_connect('localhost', $user, $pass, $db) or die('Unable to connect'); $statement = mysqli_prepare($con, 'SELECT * FROM society'); mysqli_stmt_execute($statement); mysqli_stmt_store_result($statement); mysqli_stmt_bind_result($statement, $society_id, $name, $email, $description); $society = array(); while(mysqli_stmt_fetch($statement)){ $society['society_id'] = $society_id; $society['name'] = $name; $society['email'] = $email; $society['description'] = $description; } echo json_encode($society); mysqli_stmt_close($statement); mysqli_close($con); ?> 有一个sharex和一个sharey参数:

例如:

add_subplot

这将创建一个这样的图(1 st 和2 nd 共享y轴,但3 rd 不共享):

Three plots, the left and middle one share a common y axis. The right plot has an independant y scale.

您可以在matplotlib示例"Shared axis Demo"中找到另一个示例。