问题
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
回答1:
...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:
来源:https://stackoverflow.com/questions/55729706/how-do-i-change-the-color-of-the-bars-in-my-graph-in-gnuplot