Re: [Pgfplots-features] Scatter plots with lots of classes and points
Brought to you by:
cfeuersaenger,
ludewich
From: Nick P. A. <nic...@gm...> - 2009-09-08 09:12:52
|
Hi Sebastian Let me try and explain what happens. \advance\pgfplots@numplots by-1 This increases the number of plots that the internal code uses. Every time you use an \addplot command the above also happens. And as you have already one \addplot command the value is one. Therefore we subtract one. \let\pgfplots@plotspeclist=\pgfutil@empty In order to draw the legend corresponding to the same commands used to draw the plot an array of legend specifications are saved. This array is \pgfplots@plotspeclist. So in order to reset the list we have to make it empty. \let\pgfplots@legend=\pgfutil@empty The same ís done in the above where it is the legend entries that is reset. \foreach \classNumber in {1,2,...,5} { % here you can loop through all your classes, 20... \global\advance\pgfplots@numplots by1 You internally let pgfplots know that there is one more plot \edef\tempa{ The above is merely to ensure that it works. Don't mind that command. It essentially doesn't do anything. But it won't work without it. :D \noexpand\pgfplots@addlegendentry{Class \classNumber} you then add "Class \classNumber" to the list of entries. The same command is called if you use \addlegendentry. \noexpand\pgfplots@rememberplotspec{/pgfplots/every axis plot,scatter,only marks,mark=+,\csname pgfp@scatter@class@class\classNumber\endcsname,/pgfplots/every axis plot post} you then add the specification of the plot to a list such that it can be used to draw the legend. Here "scatter,only marks,mark=+" is the same as written in addplot. The macro \pgfp@scatter@class@<classname> is the one containing the style of the class. As you have called it "class1,class2,..." you need the macro called as \csname pgfp@scatter@class@class\classNumber\endcsname }\tempa Hope this gives a little better idea of what is happening... :D Glad we could help. Nick 2009/9/8 Sebastián PEÑA SALDARRIAGA < Seb...@un...> > Hi Christian, > > I tried your solution and also the code provided by Nick (thanks Nick > !). Both solutions work for the example given, however, I don't see how > I can adapt your code to use different marker styles (like having + for > positive samples and - for negative samples) because of the explicit > definition in the matrix style. > I modified Nick Papior's code to delete the explicit mark=+, and now it > works with different markers styles (actually it sort of copy the class > style to the plot style), however, I really don't understand what's > going on there. Since I'm a plain latex user not an expert, I still hope > to find a solution I can understand and (easily) reproduce. > > Thanks to everyone for helping me out ! > > Sebastian > > Christian Feuersaenger a écrit : > > Hello Sebastian, > > > > I guess there is no direct, simple solution at hand which generates > > the legends as for other plots. > > > > I see the following solution possibilities: > > > > 1. Provide one \addplot command for every class. Then, the legend can > > be generated as usual. > > > > 2. Draw a legend using the tikz \matrix command (that's not difficult, > > see below for an example). > > > > 3. implement some sort of extra feature which draws a specialized > > legend for 'scatter/classes' feature. > > > > > > Maybe the simplest solution is (2.), although it is not completely > > automatic. I have attached example source code. Sorry for the cryptic > > ' extra description/.code' thing -- I used it because this will > > actually work in exactly the same way as a legend. > > > > REgards > > > > Christian > > > > > > > > > > Sebastián PEÑA SALDARRIAGA schrieb: > >> Hi Nick, > >> > >> I'l try to use the externalization library. I don't really need to > >> compile in-line... > >> > >> About the legend, \legend{class1,class2,...,classN} will only > >> interate through the colors in the current cycle list. Redefining a > >> cycle list with the class colors can work, however, if you use > >> different marks for each class you can no longer use this workaround > >> because marks won't cycle unless \addplot+ is called or an explicit > >> mark is defined in the \addplot command before \legend. > >> > >> Thanks for your help ! > >> > >> Sebastian > >> > >> Nick Papior Andersen a écrit : > >>> Hi Sebastian > >>> > >>> One of the things i usually do is using the Externalization library > >>> from tikz (which is also mainly implemented by Christian). In this > >>> way you only have to rebuild the graphic whenever you change > >>> parameters. Refer to the pgf/tikz manual for implementation of this. > >>> It merely ships out the picture to a pdf file. Thereby not loosing > >>> any features. > >>> And as for the maximum save memory you should be able to plot > >>> several of those files. Exactly which parameters have you edited... > >>> And to what value? If you really need to compile in-line let me know > >>> and I shall post which parameters i have changed and to what value. > >>> During my latest project i could easily fit 10+ graphs. 4 of those > >>> had and excess of 7000 points each. > >>> > >>> Hope this will help you in the right direction. The externalization > >>> library is very efficient and very easy to use! In the CVS-version > >>> pgf/tikz this is written in section 31. > >>> > >>> Regarding the legends try and play with > >>> \legend{class1,class2,...,classN}. They might need rearrangement but > >>> you can add as many legend entries separated by commas as you like. > >>> In the pgfplots manual you should read section 6.4. > >>> > >>> Regards Nick > >>> > >>> 2009/9/3 Sebastián Peña Saldarriaga > >>> <seb...@un... > >>> <mailto:seb...@un...>> > >>> > >>> Hi, > >>> > >>> I was wondering if there is anyway to generate legends from > >>> scatter classes definitions. For example given this file (you can > >>> see a sample output in attachment) > >>> > >>> \begin{tikzpicture} > >>> \begin{axis}[scatter/classes={ > >>> class1={draw=blue}, class2={draw=magenta}, [...], > >>> class20={draw=red} > >>> } > >>> ] > >>> \addplot[scatter,only marks,mark=+] plot[scatter src=explicit > >>> symbolic] coordinates { > >>> (26.1242, 14.9926) [class1] > >>> (25.5293, 15.0081) [class1] > >>> (25.4178, 15.6095) [class2] > >>> (25.563, 15.6233) [class3] > >>> (25.377, 15.3875) [class1] > >>> (26.8236, 14.5795) [class3] > >>> (25.4623, 15.3013) [class4] > >>> (26.039, 15.5919) [class5] > >>> (26.7789, 15.3903) [class17] > >>> (25.5302, 15.0964) [class9] > >>> (25.7936, 15.7839) [class15] > >>> % many many points here > >>> }; > >>> \end{axis} > >>> \end{tikzpicture} > >>> > >>> I'd like to generate legends without separating points from > >>> different classes in individual \addplot commands, is this > >>> possible ? > >>> I also have a more general question, how can I include several > >>> plots without exceding TeX memory size ? Right now I cannot > >>> include more than 4 plots with about 1k points per plot (I tuned > >>> the save-size parameter to the maximum). > >>> > >>> Thanks, > >>> > >>> Sebastian > >>> > >>> > >>> > ------------------------------------------------------------------------------ > >>> > >>> Let Crystal Reports handle the reporting - Free Crystal Reports > >>> 2008 30-Day > >>> trial. Simplify your report design, integration and deployment - > >>> and focus on > >>> what you do best, core application coding. Discover what's new with > >>> Crystal Reports now. http://p.sf.net/sfu/bobj-july > >>> _______________________________________________ > >>> Pgfplots-features mailing list > >>> Pgf...@li... > >>> <mailto:Pgf...@li...> > >>> https://lists.sourceforge.net/lists/listinfo/pgfplots-features > >>> > >>> > >> > >> > >> > >> > ------------------------------------------------------------------------------ > >> > >> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 > >> 30-Day trial. Simplify your report design, integration and deployment > >> - and focus on what you do best, core application coding. Discover > >> what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july > >> _______________________________________________ > >> Pgfplots-features mailing list > >> Pgf...@li... > >> https://lists.sourceforge.net/lists/listinfo/pgfplots-features > > > > > > > ------------------------------------------------------------------------------ > Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day > trial. Simplify your report design, integration and deployment - and focus > on > what you do best, core application coding. Discover what's new with > Crystal Reports now. http://p.sf.net/sfu/bobj-july > _______________________________________________ > Pgfplots-features mailing list > Pgf...@li... > https://lists.sourceforge.net/lists/listinfo/pgfplots-features > |