If you have a complex tikzpicture with many \addplot commands and \addlegendentry commands, references to many datasets, probably also a colorbar, and so on: is there a convenient way to only hide/show the legend or only hide/show the colorbar, or to hide all the plot lines while keeping the legend?
I want to avoid having to uncomment and edit many things and there is for example a very convenient way to hide the axis by using hide axis, somewhere within the axis options of the tikzpicture. I am looking for similar commands to hide the legend or to hide the colorbar or to hide the actual line data (plots) while still showing the correct legend (with correct colors, entries etc.).
The goal is for example to be able to create a pdf, which just shows the cropped legend (with all the correct lines in the corresponding colors of the plots and with the correct legend entries) but hides all of the rest of the figure's elements (colorbar, axis, plot lines...). Is something like this possible? I would like to avoid to create the legend manually as mentioned here: 54794
\legend(inside the axis environment) orlegend entries(in the axis options) this could easily be commented to "hide" it. The same is true forcolorbar. But I don't see the point to draw some stuff in a legend when it is not shown in the plot. Could you edit your question to let us know for what that should be good for? Maybe then it easier to think of a solution. – Stefan Pinnow Sep 22 '16 at 19:01legend to namekey which "stores" the legend and can be\refed somewhere else in the document. But that only isn't enough, because when you comment the plot of course the "\label" will also be gone. But in addition you could use theexternallibrary to externalize the legend to a (separate) PDF file which then can be included into the document. After the externalization you don't need the plot any more. Is that an option? – Stefan Pinnow Sep 23 '16 at 18:07