| 
      
      
      From: Ethan M. <eam...@gm...> - 2023-05-18 16:15:06
      
     | 
| On Thursday, 18 May 2023 05:08:36 PDT Debostuti Ghoshdastidar wrote: > > However the bars are not getting colored according to col i+1, although the > key is (please see attached image). Could you please help me understand > whats going wrong? > > Debostuti I am guessing that your gnuplot executable is not current. There was a bug that affected this specific kind of plot, fixed in the September 2022 gnuplot release (version 5.4 patchlevel 5). I should have remembered that and mentioned it before. The current release level is 5.4.6, with 5.4.7 queued for later this month. Ethan > Hi Ethan > > I followed your suggestions and made little tweaks to the script as follows: > ----------------------------------------------- > set lt 101 lw 4 lc "red" > set lt 102 lw 4 lc "pink" > set lt 103 lw 4 lc "dark-blue" > set lt 104 lw 4 lc "blue" > set lt 105 lw 4 lc "royalblue" > . > . > . > set lt 120 lw 4 lc 'white' #*set 20 custom colors* > set style data histogram > set style histogram rows > set style fill solid border lc "black" > #set style line 2 lc 'black' lt 1 lw 2 > set boxwidth 0.80 > alphabet = "GAVLIPWFYSTCMNQHKRDE" > color(category) = 100 + strstrt(alphabet, category) > plot for [i=3:10:2] 'test.dat' using > (column(i)):(color(strcol(i+1))):xtic(1):x2tic(2) lc variable > ----------------------------------------------------------------------------------------------------------------------- > > for the following test data (the real data will have all 20 amino acids in > a row): > > test.dat: > 1 Gly 0.03 G 0 A 0 V 0 I > 2 Met 0.03 M 0 A 0 V 0 I > 3 Arg 0.94 R 0 A 0 V 0 I > 5 Arg 0.94 R 0 A 0 V 0 I > 6 Tyr 0.97 Y 0 A 0 V 0 I > 7 Val 0.03 V 0 G 0 A 0 I > 8 Cys 0.88 C 0 G 0 A 0 V > 9 Glu 1.00 E 0 G 0 A 0 V > 11 Pro 0.03 R 0.09 P 0 A 0 G > 12 Ser 0.58 S 0 G 0 A 0 V > 13 His 0.03 S 0.15 R 0.21 A 0.61 H > 14 Gly 0.03 A 0.06 S 0.61 G 0 V > 15 Gly 0.06 S 0.12 A 0.21 G 0 V > > -------------------------------------------------------------------------------------------------- > > > > On Thu, May 18, 2023 at 2:10 AM Ethan Merritt <eam...@gm...> wrote: > > > On Wednesday, 17 May 2023 09:47:43 PDT Debostuti Ghoshdastidar wrote: > > > Hi Ethan > > > > > > Thank you for the solution. Each Y column will be a score for a > > particular > > > amino acid. The Y columns will be in increasing order of the score value. > > > Each Z will always correspond to a particular color we use to represent > > the > > > amino acid that will be in the corresponding y column. We will use a set > > of > > > 20 colors to represent 20 amino Acids. > > > > Ah. In that case you probably don't want "lc palette", which assumes > > a continuous range of values and a smoothly-varying color palette. > > Instead define 20 distinct colors in a convenient range of linetypes, > > say lt 101 through lt 120, indexed by the value in column Zn. > > That matches this demo from the on-line collection very closely: > > > > https://gnuplot.sourceforge.net/demo_5.4/histogram_colors.html > > > > If you have the one letter code in the Z column (P for Proline, etc) > > you could use pieces of the demo code directly. > > > > alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" > > color(category) = 100 + strstrt(alphabet, category) > > plot for [i=2:*:2] DATA using (column(i)):(color(strcol(i+1)) lc > > variable > > > > Otherwise you could define a slightly more complicated color() function > > that > > for instance maps from the 3-letter code, e.g. > > array AA = ["Ala", "Cys", "Asp", "Glu", ...] > > color(category) = 100 + sum [1:20] (category eq AA[i]) ? i : 0) > > > > cheers, > > > > Ethan > > > > > > Debostuti > > > > > > On Wed, 17 May 2023, 21:36 Ethan Merritt, <eam...@gm...> wrote: > > > > > > > On Tue, May 16, 2023 at 9:52 PM Debostuti Ghoshdastidar < > > > > deb...@gm...> wrote: > > > > > > > >> Dear Users > > > >> > > > >> I have data in the following format > > > >> > > > >> X1 Y1 Z1 Y2 Z2...Yn Zn > > > >> X2 Y1 Z1 Y2 Z2...Yn Zn > > > >> . > > > >> . > > > >> . > > > >> Xn Y1 Z1 Y2 Z2...Yn Zn > > > >> > > > >> I would like to draw a rowstacked histogram (which I know how to) > > where > > > >> the > > > >> colors for the bars are specified by the corresponding Z columns. For > > > >> example Y1 should be colored based on Z1 value, Y2 based on Z2 value, > > and > > > >> so on...mush like the use of cbrange. Could you suggest how I can > > > >> accomplish this? > > > >> > > > > > > > > set style data histogram > > > > set style histogram rows > > > > set style fill solid border lc "black" > > > > set cbrange [0:<something>] > > > > plot for [i=2:*:2] DATA using (column(i)):(column(i+1)) lc palette > > title > > > > "???" > > > > > > > > It is not clear to me how you would label or construct a legend > > describing > > > > this in a way that is easy for the viewer to understand. Perhaps > > > > superimpose > > > > a label on top of each individual box? > > > > > > > > Ethan > > > > > > > > > > > > > > > > > > > > > > > >> Thank you > > > >> > > > >> Debostuti > > > >> -- > > > >> Debostuti Ghosh Dastidar > > > >> Research Associate > > > >> PDB-India > > > >> > > > >> _______________________________________________ > > > >> gnuplot-info mailing list > > > >> gnu...@li... > > > >> Membership management via: > > > >> https://lists.sourceforge.net/lists/listinfo/gnuplot-info > > > >> > > > > > > > > > > > > > > > > > > > |