如何在gnuplot中更改图形中条形的颜色? [英] How do I change the color of the bars in my graph in gnuplot?

查看:85
本文介绍了如何在gnuplot中更改图形中条形的颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有导入数据并作图的代码,但所有条形均为紫色,我想更改每种颜色.我注意到的另一个问题是,它在图形上显示了文件位置,我不希望在该位置.

 设置标题"FASP的精度图"设置xlabel功能"设置ylabel(%)"设置boxwidth 0.9绝对设置样式填充实心1.00边框lt -1设置键固定右上垂直右否反向增强型自动字幕设置样式增量默认设置样式直方图聚类间隙1标题textcolor lt -1设置数据文件缺少-"设置样式数据直方图设置xtics边框的比例为0,0 nomirror旋转-45 autojustify设置xtics norangelimit设置xtics()设置xrange [*:*] noreverse写回设置x2range [*:*] noreverse写回设置yrange [0:100]不反向写回设置y2range [*:*] noreverse写回设置zrange [*:*] noreverse写回设置cbrange [*:*] noreverse写回设置rrange [*:*] noreverse写回使用1:3:xtic(2)带框绘制'C:\ Users \ John \ Desktop \ Lomotey \ FASP.dat的神秘分配' 

解决方案

...以防万一您尚未找到解决方案...例如,您可以在数据中添加一列,将颜色定义为十六进制数字,例如 0xff0000 为红色.然后在带有 linecolor rgb变量的plot命令中,它将获取第4列的颜色(实际上是 1:3:4:xtic(2)的最后一列,而不是计数 xtic(2).)为了删除作为图例的文件名,您可以在plot命令或前一行 unset key 中添加 notitle .

如果您希望提供颜色名称而不是颜色编号,请检查此

I have the code importing the data and plotting it but all the bars are purple and I want to change up the colors for each. Another issue I noticed is that it shows the file location on the graph and I don't want it on there.

set title "Accuracy Plot for the FASP" 
set xlabel "Fucntion"
set ylabel "(%)"
set boxwidth 0.9 absolute
set style fill   solid 1.00 border lt -1
set key fixed right top vertical Right noreverse noenhanced autotitle nobox
set style increment default
set style histogram clustered gap 1 title textcolor lt -1
set datafile missing '-'
set style data histograms
set xtics border in scale 0,0 nomirror rotate by -45  autojustify
set xtics  norangelimit 
set xtics   ()
set xrange [ * : * ] noreverse writeback
set x2range [ * : * ] noreverse writeback
set yrange [ 0 : 100 ] noreverse writeback
set y2range [ * : * ] noreverse writeback
set zrange [ * : * ] noreverse writeback
set cbrange [ * : * ] noreverse writeback
set rrange [ * : * ] noreverse writeback
plot 'C:\Users\John\Desktop\Mystery Assignment for Lomotey\FASP.dat' using 1:3:xtic(2) with boxes

解决方案

...in case you haven't found yet a solution yourself... For example, you could add a column to your data defining the color as hexadecimal number, e.g. 0xff0000 for red. Then in the plot command with linecolor rgb variable it will take the color from column 4 (actually, the last column of 1:3:4: xtic(2), not counting xtic(2).) In order to remove the file name as legend you can add notitle in the plot command or in a previous line unset key.

If you prefer to give color names instead of color numbers, check this gnuplot: apply colornames from datafile

Code:

### change color of boxes
reset session

$Data <<EOD
1  One     1  0xff0000
2  Two     4  0x00ff00
3  Three   9  0x0000ff
4  Four   16  0xff00ff
5  Five   25  0xffff00
6  Six    36  0x00ffff
EOD

set boxwidth 0.7
plot $Data u 1:3:4:xtic(2) w boxes fill solid 1.0 lc rgb var notitle
### end of code

Result:

这篇关于如何在gnuplot中更改图形中条形的颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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