gnuplot - Gnuplot:如何绘制相反的条形图或金字塔条形图
问题描述
是否可以在 gnuplot 中使用两个正 y 轴?这只是该问题的一个简单示例。
情节.gp:
reset
set style fill solid 1
set boxwidth 0.8 relative
plot 'data1.dat' index 1 using 1:2 with boxes title 'A' ,\
'' index 2 using 1:(-$2) with boxes title 'B'
而不是使用1:(-$2)
我想1:2
在 plot.gp 的最后一行使用。
数据1.dat:
0.12 0.024
0.15 0.132
0.18 0.241
0.22 0.136
0.12 0.039
0.15 0.219
0.18 0.197
0.22 0.155
从:
到:
解决方案
答案与theoz中的答案相同,只是 y2 标签移到图的左侧,并且该set link y2
命令用于概括轴反转。
您可以调整偏移量graph -1.03
以叠加“0”标签,然后通过将 y2 tic 范围更改为 来删除重复的“0”标签set y2tics 0.1,0.1
。
$Data <<EOD
0.12 0.024
0.15 0.132
0.18 0.241
0.22 0.136
0.12 0.039
0.15 0.219
0.18 0.197
0.22 0.155
EOD
set style fill transparent solid 0.5
set boxwidth 0.8 relative
set xzeroaxis ls -1
set yrange[-0.3:0.3]
set ytics 0,0.1
set mytics 2
# Set y2 axis to exact mirror of y1
# Shift tic labels to the left and use right-justified text
set link y2 via -y inv -y
set y2tics 0,0.1
set y2tics offset graph -1.03 right
plot $Data u 1:2 index 0 axis x1y1 w boxes title 'A' ,\
'' u 1:2 index 1 axis x1y2 w boxes title 'B'
推荐阅读
- python - 下一步和对话处理程序有什么区别?
- spring-boot - 使用 github Oauth2 登录进行验收测试
- c# - Resources.resx 动态更改背景图像时出错
- java - QueryDSL JPA 中 @ElementCollection 的复合子查询
- c# - c# 在类嵌套结构中引用非静态类成员
- java - Spring Boot 返回没有 ResponseBody 注释的纯文本
- wordpress - 如果使用相同的电子邮件注册,如何在仪表板中继承父帐户 ID
- laravel-5 - Laravel 8 UniSharp File Manager 3 - 图片已上传但未显示
- installation - 使用纱线安装的新 Nuxtjs 不起作用
- assembly - 静态和动态链接,PLT需要什么?