koji-kojiro / matplotlib-d

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can't assign matplotlib figure object to variable.

RJaBi opened this issue · comments

Currently it isn't possible to assign a matplotlib object to a variable. This might be useful as in

fig, ax = plt.subplots()

of the python code example http://matplotlib.org/examples/api/patch_collection.html .

Sample code demonstrating this is,

import plt = matplotlibd.pyplot;

void main()
{
auto figure = plt.figure;
}

results in the error:

Performing "debug" build using /home/user/Downloads/dmd/dmd2.072.2/linux/bin64/dmd for x86_64.
matplotlib-d 0.1.4: building configuration "library"...
Running pre-build commands...
simple_example ~master: building configuration "application"...
Running pre-build commands...
source/app.d(5,8): Error: variable app.main.figure type void is inferred from initializer figure(), and variables cannot be of type void
source/app.d(5,20): Error: expression figure() is void and has no value
/home/user/Downloads/dmd/dmd2.072.2/linux/bin64/dmd failed with exit code 1

This isn't actually the use I need (I need a PdfPages object from the matplotlib.backends.backend_pdf which I can import successfully with some small changes to matplotlib-d -> #8 ) but the error is the same and this is in the repo.

Finally thanks for this repo, it's a promising idea.

Thank you for using matplotlib-d.

The functions included in matplotlibd.pyplot parse given arguments and translate to corresponding python script strings. Then, translated strings is to append to matplotlibd.pyplot.py_script. They therefore don't return any values and generate any objects.

Due to the above, error occuers in your PR(#8).

Assigning figure object to variable is very useful as you mentioned, but it takes many changes and much effort to implement.Therefore, it might need little time.
Please wait next update.

Best regards.