Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Writing to pgfAxis environment from other function than drawAxes() #35

Closed
blubbafett opened this issue Jul 20, 2011 · 4 comments
Closed

Comments

@blubbafett
Copy link
Contributor

In drawAxes() this is written:

% Store a pointer to the current pgfplotsEnvironment axis environment
% as plot objects further below in the hierarchy might want to append
% something.
% One example is the required 'ybar stacked' option for stacked bar
% plots.
m2t.currentHandles.pgfAxis = env;

which makes me believe that I can update the content (m2t.currentHandles.pgfAxis.options) from another nested function before the content is printed to the actual file.

Thus, if I in f.ex drawLine() want to append something, I could write:

pgfAxis = m2t.currentHandles.pgfAxis.options;
newOpts = blablabla;
pgfAxis = appendOptions( pgfAxis, newOpts );
m2t.currentHandles.pgfAxis.options = pgfAxis;

But after trying for a while now it's obvious I'm missing out on something; the options are indeed updated in the struct, but not printed to the file.

So the question is; what am I missing here?

@blubbafett
Copy link
Contributor Author

Just made a hack in the savToFile() function for testing;

m2t.content.children{1}.options = appendOptions( m2t.content.children{1}.options, m2t.currentHandles.pgfAxis.options );

Suggestions for improvement are welcome. :)

@nschloe
Copy link
Member

nschloe commented Jul 20, 2011

I don't understand the issue -- you wanna append something to the options of the current enviroment and it doesn't work?

@blubbafett
Copy link
Contributor Author

I wanted to write some options under

\begin{axis}[%
*bla,
*bla,
*bla,
-new_bla,
-new_bla]coordinates{xxxxxxx}
\end{axis}

where *bla is written from the drawAxes() function and -new_bla from any other function. I.e. if I want to add the z-limits for a 3D plot, they have to be placed as options in the axis environment, and not as options in the surf environment (\addplot3[surf]) . However, I when in drawSurface() I couldn't find a way to directly access the axis environment instead of the surface which I was plotting; hence the hack I mentioned. But it works as it is now, but as mentioned, not the cleanest solution. Should be easy to fix once I understand how to append the new options directly to the axis environment (env.options in drawAxes()).

@nschloe
Copy link
Member

nschloe commented Jul 21, 2011

Ah okay. Well, that had worked before but broke at some point such that, for example, stacked bar plots (which need 'ybar stacked' in the containing axes environment) didn't work anymore.
I've tried to fix this now by providing m2t.currentAxesContainer of which you could access m2t.currentAxesContainer.options to append something there. Closing this for now, please reopen if necessary.

@nschloe nschloe closed this as completed Jul 21, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants