Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

This is really more of a question to satisfy personal curiosity than to solve a real problem.

When choosing the colour schemes for my plots, I try to select colours that will work well with the amount of items involved in the plot. This means using sets of colours that are above all aesthetically pleasing, but also that contrast well, etc. (eg. schemes created with a website like this).

However, I was wondering if it would be possible to define a set of 2,3,4,...,n colours that work well, and have pgfplots (or some other package?) select automatically from the one that matches the amount of entries.

I looked around for similar questions, but I didn't seem to find anything. The colour sets could be defined as cycle lists, but it's the automatic selection that I'm wondering about. Can this be done? Any ideas?

share|improve this question

1 Answer 1

This is just a longish comment. I might be wrong in understanding the workflow and hopefully I'll be corrected if so.

In pgfplots things do not happen all at once. First your plot commands together with the axis options are parsed and stored as PGF paths. Then a visualization scheme kicks in (and I'm not 100% sure about the order) and path colorings, legend styles etc. are assigned. Then they are drawn with low level TikZ/PGF commands.

In order to select a cycle list, the plots need to be collected already such that they are counted. But that would probably be too late to change the drawing options. I don't think this functionality is supported off-the-shelf.

Note that this is a very rough description, there are many things checked in each layer so don't take this too literal.

But if you are willing to provide the number of plot items then it's a matter of defining a style with an argument that selects the predefined plot cycle list.

share|improve this answer
1  
It shouldn't be that much of a problem to provide the number of items in the list beforehand as an option of sorts I think. Although I think you're probably right with the points you make. –  Mythio Feb 25 '13 at 21:53
    
I guess that is the real problem: the amount of information that is available to pgfplots at any given time, and the steps it takes in processing its data. I was thinking, for example, of plots that get their input from files that may even be automatically generated. I agree that in most cases this is not really a problem, but hey, I thought it'd be cool to ask and see what solutions (if any) come up. :) –  jja Feb 25 '13 at 23:01
    
@jja Don't get me wrong, it's a nice question. It's just seems quite tedious to hack into the right place in the right time. But I've been wrong before so I'll say let's wait for Christian's opinion. Then probably I'll need to delete this :) –  percusse Feb 26 '13 at 2:16
    
@percusse your answer is correct and complete: the cycle list is evaluated while surveying the plots and the number of plots is unknown until that survey has been finished. The expected way for such a style would be to make a couple of cycle lists which match and select them manually in advance, like size <10 cycle list or so. –  Christian Feuersänger Mar 8 '13 at 19:50

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.