我有导入数据并作图的代码,但是所有的条形都是紫色的,我想改变每种颜色。我注意到的另一个问题是,它在图形上显示了文件位置,我不希望在该位置。
#loads the asciified image ("/home/userX/Documents/Programmazione/Python projects/imgascii/myascify/ascimg4")
#creates a sheet "foglio1", same number of lines as the asciified image, and distributes text on it on a randomised line
#create the sheet foglio1
def create():
ref = open("/home/userX/Documents/Programmazione/Python projects/imgascii/myascify/ascimg4")
charcount = ""
field = []
for line in ref:
for c in line:
if c != '\n':
charcount += ' '
if c == '\n':
charcount += '*' #<--- YOU GONNA NEED TO MAKE THIS A SPACE IN A FOLLOWING FUNCTION IN THE WRITER.PY PROGRAM
for i in range(50):#<------- VALUE ADJUSTMENT FROM WRITER.PY GOES HERE(default : 50):
charcount += ' '
charcount += '\n'
break
for line in ref:
field.append(charcount)
return(field)
#turn text in a list of lines and trasforms the lines in a list of strings
def poemln():
txt = open("/home/gcg/Documents/Programmazione/Python projects/imgascii/writer/poem")
arrays = []
for line in txt:
arrays.append(line)
txt.close()
return(arrays)
#rander is to be called in ripimg()
def rander(rando, fldepth):
riplns = []
for i in range(fldepth):
riplns.append(randint((rando)-1,(rando)+1)
return(riplns) #<---- THIS RETURN GIVES SyntaxError upon execution
#opens a rip on the side of the image.
def ripimg():
upmost = randint(160, 168)
positions = []
fldepth = 52 #<-----value is manually input as in DISTRIB function.
positions = rander(upmost,fldepth)
return(positions)
答案 0 :(得分:0)
...如果您自己尚未找到解决方案...
例如,您可以在数据中添加一列,将颜色定义为十六进制数字,例如0xff0000
为红色。然后在带有linecolor rgb variable
的plot命令中,它将采用第4列的颜色(实际上是1:3:4: xtic(2)
的最后一列,不包括xtic(2)
。)
为了删除作为图例的文件名,可以在plot命令或前一行notitle
中添加unset key
。
如果您希望使用颜色名称而不是颜色编号,请选中此gnuplot: apply colornames from datafile
代码:
### 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
结果: