Message Boards Message Boards

2
|
2618 Views
|
5 Replies
|
5 Total Likes
View groups...
Share
Share this post:

Extraneous graphics image from DensityPlot3D via MathKernel in NetLink API

Posted 2 years ago

I have a .Net application calling through the NetLink MathKernel class to compute a plot using DensityPlot3D[], and though it returns the expected plot graphic in the MathKernel.Graphics[] array (as element [1] of that array), it also returns a graphic showing three planes with grid lines which I don't need/want (as element [0] of that array): GridPlaneGraphic

Is there a way to have DensityPlot3D NOT return this unwanted graphic? Or am I maybe implicitly asking for it through some parameter I'm providing to DensityPlot3D? The parameters I am providing to DensityPlot3D are:

,PlotLegends->None,PerformanceGoal->"Quality",OpacityFunction->Function[f,f],ColorFunction->(Blend[{White,Blue},#]&),ViewPoint->Front

The same computation (call to DensityPlot3D) made through the Mathematica (Home Edition) client does not return this extraneous graphic. This is all using Mathematica v13.0

Insights/suggestions appreciated.

Thanks.

POSTED BY: Dave Boll
5 Replies
Posted 2 years ago

The workaround of only using the last graphic returned doesn't really work for my situation as the Wolfram Language sent through NetLink is provided by a user at run time (i.e. my application has no practical way to know how many or what kinds of graphics will be returned, and thus no way to know which ones to ignore, etc.).

Is there a way to get a sense of when these issues (at least the "too many plots" problem) might be addressed by the product group?

I understand product fix priorities are at least in part driven by impact of defect, etc. So this particular bug might be further down the list, but was just wondering if there might be a way to know coarse time frames.

Thanks.

POSTED BY: Dave Boll

Okay, I can 100% reproduce what you get. I don't understand why this is, but I can use this to poke some people at Wolfram.

PS C:\Users\arnou\Downloads> .\program.exe
Initializing NetLink MathKernel ...
Running query:
DensityPlot3D[x y z, {x, -1, 1}, {y, -1, 1}, {z, -1, 1}]

Result:
        -Graphics3D-
Mathematica returned 2 images
Saving image #0 to file 'plot_image_0.jpeg'
Saving image #1 to file 'plot_image_1.jpeg'

So far this seems specific to DensityPlot3D (I tried things like Plot3D, ContourPlot3D, and even Graphics3D[Sphere[]] and none of them are showing this behavior).

This is also interesting: Put the DensityPlot3D in a Do loop (as shown) and you get even more images:

PS C:\Users\arnou\Downloads> .\program.exe
Initializing NetLink MathKernel ...
Running query:
Do[ DensityPlot3D[1.0, {x, -1, 1}, {y, -1, 1}, {z, -1, 1}], 3]

Result:
        Null
Mathematica returned 6 images
Saving image #0 to file 'plot_image_0.jpeg'
Saving image #1 to file 'plot_image_1.jpeg'
Saving image #2 to file 'plot_image_2.jpeg'
Saving image #3 to file 'plot_image_3.jpeg'
Saving image #4 to file 'plot_image_4.jpeg'
Saving image #5 to file 'plot_image_5.jpeg'

Update: I received an update from our development team and this is an issue (bug) in DensityPlot3D. It can be reproduced without NETLink as follows:

Block[{$DisplayFunction = Echo}, DensityPlot3D[x y z, {x, 0, 1}, {y, 0, 1}, {z, 0, 1}]]

Update: It's not the only function that has this behavior:

Block[{$DisplayFunction = Echo}, ComplexPlot[0.0, {z, -1 - I, 1 + I}, PlotLegends -> Automatic]]

My recommendation, for now, is to expect one or more graphics being returned to NETLink and using the last graphic as the one to use in your NETLink code.

Another update: I have found a function (and there are possibly others) which do not return any image, even though they should. For example

PS C:\Users\arnou> .\program.exe
Initializing NetLink MathKernel ...
Running query:
ListLinePlot[{1,1,2,3,5,8}]

Result:
        -Graphics-
Mathematica returned 0 images

(This will also be reported to the developers...)

POSTED BY: Arnoud Buzing
Posted 2 years ago

Any way to get a sense of when a fix for this problem might be available?

Thanks.

POSTED BY: Dave Boll

Do you have an exact DensityPlot3D command that you are sending through NETLink?

Does it happen with any (simple) DensityPlot3D command, or is a specific to your own code? For example, do you see the same problem with something simple like this:

DensityPlot3D[x y z, {x, -1, 1}, {y, -1, 1}, {z, -1, 1}]
POSTED BY: Arnoud Buzing
Posted 2 years ago

Yes, that simple DensityPlot3D[] query, executed via my code through the NetLink interface, yields the same "extraneous" graphic (as well as the requested one). And when run through the Mathematica client, it does not return the extraneous graphic.

I'm still wondering if there's maybe something about how I'm making the call through NetLink that is causing this, but my use of the NetLink MathKernel class is pretty straightforwardly "the same" as the example provided with the NetLink download (always the claim of a programmer suffering self-inflicted wounds :-) ).

I've attached the source for a simple .net c# console app (Program.cs) that runs the query you mention above, and it shows the extraneous graphic being returned (saves each returned image to a jpeg file that you can examine).

Thanks for investigating.

Attachments:
POSTED BY: Dave Boll
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract