Can't use palette to fill object with colour

会有一股神秘感。 提交于 2019-12-24 19:52:41

问题


I was trying to plot number of particles in a square lattice. and I need each one to be coloured different. So I tried using palette.. by picking some random numbers but it always gives me black rectangles.. what should I do?

set obj rect from 1,5 to 2,6 fc palette 0.454545 → this is what is not working for me.

This is the image with all same color. I need different colour for each particle:


回答1:


Plot using the boxxyerror style, and fill the boxes:

set size ratio -1
set style fill solid
plot 'file.dat' using 1:2:(0.1):(0.1):3 linecolor palette with boxxyerror

This would plot a square of size 0.2 at each position given by the first and second columns. The color is taken from the third column and mapped to the current palette. You must adapt that to your actual data format.

Working example using random pseudo-data ('+'):

set xrange [-0.05:1.05]
f = "int(rand(0) * 20)/20.0"
set style fill solid
set size ratio -1
plot '+' using (@f):(@f):(0.025):(0.025):(@f) linecolor palette notitle with boxxyerror




回答2:


see What I gotI could get this working,what I did is initially set the pallette by the commands like "set palette model RGB defined ( 0 'green', 1 'blue', 2 'red', 3 'orange' )" ,"set palette model HSV defined ( 0 0 1 1, 1 1 1 1 )"(I got these from here-http://gnuplot.sourceforge.net/demo/pm3dcolors.html). Then I set rectangles as "set obj rect from x1,y1 to x2,y2 fc palette frac 0.57" . But I could see that there were some gaps between the squares and I could understand that it was because of problem with border so I added this "fs border palette frac 0.57",same colour. Even after doing these It wouldn't come out by the simple command "plot 0". So I had to modify it as "plot 0 lc palette frac 0.24 " (0.57 / 0.24 I just meant as example.. as you know it would be anything between 0 and 1). Now to remove the colorbox I used "unset colorbox". But why I had to write "plot 0 lc palette frac 0.24 " ?, to wakeup the palette? ,Is there any other way to show out the rectangles that we have already set without using a plot command ?



来源:https://stackoverflow.com/questions/52510434/cant-use-palette-to-fill-object-with-colour

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!