PatrickT

Dr. Patrick T

2108 Reputation

18 Badges

16 years, 301 days

MaplePrimes Activity


These are replies submitted by PatrickT

@Robert Israel , @epostma

thanks for this explanation Robert, indeed I can see what you mean.

would it be feasible to extract the data from the plottools:-transform projection and recreate the plot from there, remapping the colors at that stage?

To begin with, I tried this:

test := eval(pt(p), SHADING=(()->())):
plottools:-getdata(test);
Error, (in plottools:-getdata) Array index out of range

but that's almost certainly my misunderstanding the proper use of plottools:-getdata in this context.

Right-o so let me see if I understand SHADING= (()->()) properly.

From:

plottools:-getdata(plots:-display(pt(p)));
Error, (in plots:-display) unknown plot object: SHADING

I infer that the 2D plot interpreter (or whatever that's called) doesn't understand the 3D-specific option SHADING, which is the internal language code for shading, we must therefore manually remove it.

So the shading will disappear. I understand. Fair enough.

Might there be a way to extract from the original 3D plot the color associated with each point and use that to re-colour point by point the transformed points in 2D ?

@Robert Israel , @epostma

thanks for this explanation Robert, indeed I can see what you mean.

would it be feasible to extract the data from the plottools:-transform projection and recreate the plot from there, remapping the colors at that stage?

To begin with, I tried this:

test := eval(pt(p), SHADING=(()->())):
plottools:-getdata(test);
Error, (in plottools:-getdata) Array index out of range

but that's almost certainly my misunderstanding the proper use of plottools:-getdata in this context.

Right-o so let me see if I understand SHADING= (()->()) properly.

From:

plottools:-getdata(plots:-display(pt(p)));
Error, (in plots:-display) unknown plot object: SHADING

I infer that the 2D plot interpreter (or whatever that's called) doesn't understand the 3D-specific option SHADING, which is the internal language code for shading, we must therefore manually remove it.

So the shading will disappear. I understand. Fair enough.

Might there be a way to extract from the original 3D plot the color associated with each point and use that to re-colour point by point the transformed points in 2D ?

@acer 

thanks for that acer, typesetting is a rather subtle art!

@epostma

Thanks Eric, this looks rather promising.

Your first attempt looks like Chinese shadows (read: beautiful):

However, I (accidentally) noticed that by applying plots:-display() it was possible to see a little more,

eval(pt(p), SHADING=(()->())):
testPlot := plots:-display(%):
plots:-display(%);

with some colors, one gets:

While the full range of colors is lost, it is possible to see a little more what's going on.

Exporting as postscript results in a huge file. Converting to pdf with ps2pdf and cropping is significantly smaller. But it also looks quite different (omitting the axes).

testPlot3.pdf

Thanks a lot, I hope this approach will yield fruit. I wonder if the ImageTools package could be used to extract the colors from the plot structure. I haven't had time to explore this, but the following exchange contains useful ideas that may or may not be applicable (but just in case, let me link to it):

http://www.mapleprimes.com/maplesoftblog/6851-Mandelbrot-Mania-With-Maple

EDIT: wrong url fixed

@epostma

Thanks Eric, this looks rather promising.

Your first attempt looks like Chinese shadows (read: beautiful):

However, I (accidentally) noticed that by applying plots:-display() it was possible to see a little more,

eval(pt(p), SHADING=(()->())):
testPlot := plots:-display(%):
plots:-display(%);

with some colors, one gets:

While the full range of colors is lost, it is possible to see a little more what's going on.

Exporting as postscript results in a huge file. Converting to pdf with ps2pdf and cropping is significantly smaller. But it also looks quite different (omitting the axes).

testPlot3.pdf

Thanks a lot, I hope this approach will yield fruit. I wonder if the ImageTools package could be used to extract the colors from the plot structure. I haven't had time to explore this, but the following exchange contains useful ideas that may or may not be applicable (but just in case, let me link to it):

http://www.mapleprimes.com/maplesoftblog/6851-Mandelbrot-Mania-With-Maple

EDIT: wrong url fixed

@pagan 

This is fantastic pagan, thanks a lot! Works like a charm.

I understand the broad steps inside the cast procedure, but the details are beyond me.

For a minimal illustration of the use of the cast procedure,

plot( 0, 'caption' = k*Pi/10 );
plot( 0, 'caption' = cast(k*Pi/10) );

The first one yields the rather "unnatural" \frac{1}{10} k \pi, while the second yields the more "natural" \frac{k \pi}{10}.

What's special, I wonder, about the typesetting rules inside a plot caption ?

Note that within the Maple worksheet,

seq(k*Pi/4,k=1..4);

which is "natural", but the `cast` procedure doesn't work inside the typeset() environment for captions of a plot,

seq(cast(k*Pi/4),k=1..4);

Of course it's no longer needed, since Maple does the work anyway. But I'm curious, is there some typesetting setting that needs to be active for the cast procedure to work as expected? (I tried interface(typesetting=extended): but it has had no effect).

EDIT: pagan, I forgot to mention that the axis labels are now properly printed. That's great.

@pagan 

> the piecewise solution doesn't look shorter or simpler here either

you're absolutely right.

I had in mind cases with more parameters, e.g. from my current work,

eta  = '(r,u)-> s*(A*((a*A)/(r+d))^(a/(1-a))-d*((a*A)/(r+d))^(1/(1-a))-u)'

where r and u are functions of time, but s,a,A,r,d are constant.

I use the function eta(r,u) in several places in the worksheet, and I have memorized the order of its arguments (r then u). If I were to treat the other parameters formally too, I'd have to write something like this:

eta  = '(r,u,a,A,d,r,s)-> s*(A*((a*A)/(r+d))^(a/(1-a))-d*((a*A)/(r+d))^(1/(1-a))-u)'

For one, I'd find it difficult to remember the order (alphabetical? what about the order of a and A...). But more importantly, depending on the functional assumptions I make at the top of the worksheet, my function eta has neither the same parameters nor the same number of parameters, so calls to eval(eval(eta(r,u,a,A,d,r,s),functions),parameters) wouldn't work as they stand. I'd need to find a way to deal with eta's arguments varying from simulation to simulation.

Acer's suggestion to use capital letters for the formal parameters within the procedure is attractive in general. However, in this instance, the r,u,a,A,d,r,s symbols I'm using here are exactly as they will appear in the paper (some of the notation is conventional, in particular the a and A). I think it's useful for myself (especially my future selves), my coauthors (none for this particular paper, as it happens), for the referees who will check (or would be expected to check) the calculations in the worksheet, and in dreamland for future readers who would be eager enough to rerun the simulations. Replacing the capital A notation by, say, b would be fraught with danger (why do I sound overly dramatic?).

I'm sure some of my predicaments would be avoided by better coding practice. I'm learning. So thanks for your advice, I'm taking it all in.  ;-)

@pagan 

> the piecewise solution doesn't look shorter or simpler here either

you're absolutely right.

I had in mind cases with more parameters, e.g. from my current work,

eta  = '(r,u)-> s*(A*((a*A)/(r+d))^(a/(1-a))-d*((a*A)/(r+d))^(1/(1-a))-u)'

where r and u are functions of time, but s,a,A,r,d are constant.

I use the function eta(r,u) in several places in the worksheet, and I have memorized the order of its arguments (r then u). If I were to treat the other parameters formally too, I'd have to write something like this:

eta  = '(r,u,a,A,d,r,s)-> s*(A*((a*A)/(r+d))^(a/(1-a))-d*((a*A)/(r+d))^(1/(1-a))-u)'

For one, I'd find it difficult to remember the order (alphabetical? what about the order of a and A...). But more importantly, depending on the functional assumptions I make at the top of the worksheet, my function eta has neither the same parameters nor the same number of parameters, so calls to eval(eval(eta(r,u,a,A,d,r,s),functions),parameters) wouldn't work as they stand. I'd need to find a way to deal with eta's arguments varying from simulation to simulation.

Acer's suggestion to use capital letters for the formal parameters within the procedure is attractive in general. However, in this instance, the r,u,a,A,d,r,s symbols I'm using here are exactly as they will appear in the paper (some of the notation is conventional, in particular the a and A). I think it's useful for myself (especially my future selves), my coauthors (none for this particular paper, as it happens), for the referees who will check (or would be expected to check) the calculations in the worksheet, and in dreamland for future readers who would be eager enough to rerun the simulations. Replacing the capital A notation by, say, b would be fraught with danger (why do I sound overly dramatic?).

I'm sure some of my predicaments would be avoided by better coding practice. I'm learning. So thanks for your advice, I'm taking it all in.  ;-)

@Alejandro Jakubi 

Thanks Alejandro, I have sent the Maplesoft Help support team a message suggesting that these links be added to the ditto operator page.

@Alejandro Jakubi 

Thanks Alejandro, I have sent the Maplesoft Help support team a message suggesting that these links be added to the ditto operator page.

@acer 

thanks for your help, so let me answer your questions in sequence,

> 3D spacecurves versus 3D surface.

It's mostly spacecurves, I think (I'm not entirely sure about the technical name of the plot structure). Please refer to the attached worksheet for an example of the plots I'm trying to export. (I do have some plots in which I combine these with surfaces, but I haven't been able to make them intelligible so I don't currently intend to use them outside of Maple. I haven't included one such in the worksheet).

I'm not sure what you mean about lprinting. I have read ?lprint, but I'm still not sure how it relates to a plot. In the attached worksheet, if you execute the whole worksheet it should export several plots, one 3D plot in postscrit, one 3D plot in png, one animated plot in gif, and one 2D plot in postscript. I expect that you will find like me that, with Standard Maple 15, the best looking plot are 2D postcript, while the 3D png or 3D gif are not bad but look poor if enlarged, while the 3D postscript is a mess.

I hope this answers your question.

> Do you really need Postscript, or would a high quality gif/bmp be adequate?

Eventually I will use either pdf or png/jpeg. I find that converting from ps to pdf works well. I haven't before used gif or bmp in LaTeX. I'm open to any format if I can eventually find a way to import it into a LaTeX pdf document.

A couple of months ago I thought that x3d would be the way forward, but my experiments with that format led to a dead end -- while it was nice to have them rotate around, the plots looked even worse (in addition to poor quality of the image, the axis labels and ticks and axes had all sorts of problems, different problems depending on which x3d software I tried, and I tried quite a few of them: ayam, deepview, flux, freewrl, h3dviewer, instantreality, seemless3d, swirlviewer, view3dscene, x3dom, xj3d... none of them satisfied my needs).

> what aspects of the 3D plots are so bad that you are so desperate to avoid them?

Once enlarged to the size I will use, approx half of A4, and after import into a pdf document via LaTeX, the definition of the axes, labels, and curves is disappointing --- the black lines are not sharp enough, the colors are faint in places, small patches of the figure are altogether blurred. And while my most pressing need is to get pretty graphs for onscreen viewing of a pdf, I would also love to be able to use 3D graphs in lectures, projected on a wide screen from a pdf document. (there is quality loss when projecting, so minimizing the quality loss within the pdf document itself is rather important).

P.S. Thank you all for your help, please bear with me for a day or so as I take it all in and experiment,  ;-)

EDIT: forgot to attach the promised worksheet. Here it is. Convert3dPlotTo2DPlo.mw


Preben, Joe, Robert, acer, thank you so much for your suggestions. This has been a very useful exchange, I have learned several things. I am particularly grateful for the pains you took to explaining the details of what was going on.

Preben, very interesting use of piecewise, your code is the shortest too, it does achieve what I was after.

Robert, I like that your method makes clear the order of evaluation, and it's nice to learn how to get around the division by zero, this trick will be potentially useful elsewhere.

Using subs I can also simplify the code in places where I intend to use both the functional forms and the parameter values at once, e.g.


model := subs(Parameters1,Functions);
eval(U(c), model); # clearer than eval(eval(...

  model := [U = proc (c) local one; if 2 = 1 then log(c) else one := 1; (1/c-1)/(one-2) end if end proc]


it helped me understand what was going on to actually see the statement if 2=1.

Joe, thanks, working out the meaning of the following line was well worth the effort, code that may prove useful in the future too,

  if not [args]::list(numeric) then return 'procname'(args) end if;

acer, yes I fully agree with the practice of using different symbols in the definition of the proc and in its evaluation, I'll try to be consistent with that in the future. Thanks for your guidance.

Joe, I'm curious about the use of the percentage sign in front of a symbol, as in %s, I couldn't find documentation about this particular use of % ... Oh, wait! I do find information about it as I write, by searching ?value. Here:
<quote>


any function whose name starts with the % character, as in %F, is an inert representation for the function F. This feature provides inert representations for any Maple or user-defined function. [...] During computations, inert functions remain unevaluated (the operations they represent remain unperformed). The value command maps these inert functions [...] into the corresponding active functions.

<\quote>

Example: %Pi; value(%Pi);

A search for % returns "The Ditto Operators" section Maple's help pages. I don't see there a link to "value."  This is, I think, a shortcoming of the ditto help page.

That's quite a few tricks to add to my bag. Thanks so much to all of you for your help.


Preben, Joe, Robert, acer, thank you so much for your suggestions. This has been a very useful exchange, I have learned several things. I am particularly grateful for the pains you took to explaining the details of what was going on.

Preben, very interesting use of piecewise, your code is the shortest too, it does achieve what I was after.

Robert, I like that your method makes clear the order of evaluation, and it's nice to learn how to get around the division by zero, this trick will be potentially useful elsewhere.

Using subs I can also simplify the code in places where I intend to use both the functional forms and the parameter values at once, e.g.


model := subs(Parameters1,Functions);
eval(U(c), model); # clearer than eval(eval(...

  model := [U = proc (c) local one; if 2 = 1 then log(c) else one := 1; (1/c-1)/(one-2) end if end proc]


it helped me understand what was going on to actually see the statement if 2=1.

Joe, thanks, working out the meaning of the following line was well worth the effort, code that may prove useful in the future too,

  if not [args]::list(numeric) then return 'procname'(args) end if;

acer, yes I fully agree with the practice of using different symbols in the definition of the proc and in its evaluation, I'll try to be consistent with that in the future. Thanks for your guidance.

Joe, I'm curious about the use of the percentage sign in front of a symbol, as in %s, I couldn't find documentation about this particular use of % ... Oh, wait! I do find information about it as I write, by searching ?value. Here:
<quote>


any function whose name starts with the % character, as in %F, is an inert representation for the function F. This feature provides inert representations for any Maple or user-defined function. [...] During computations, inert functions remain unevaluated (the operations they represent remain unperformed). The value command maps these inert functions [...] into the corresponding active functions.

<\quote>

Example: %Pi; value(%Pi);

A search for % returns "The Ditto Operators" section Maple's help pages. I don't see there a link to "value."  This is, I think, a shortcoming of the ditto help page.

That's quite a few tricks to add to my bag. Thanks so much to all of you for your help.

@zoli123 

downloaded your file with extension .msim, couldn't get Maple to read it in standard and classic modes, couldn't get notepad++ to read it, so not sure what to do with it.

EDIT: Geez, that was a stupid comment, of course it's a maplesim file, thanks Joe.

@acer

thanks for your help, once again, acer, and sorry for not properly understanding your questions.

I have checked and have been able to run the examples the ?Compiler help-page gives. The watcom compiler seems to be properly installed to work with the 32 bit version. In the sense that it spits out the same output reported in the help page. And yes, I do get the message  "IBM INTEL NT". But, as you say, I have not set it up to use 64 bit and MSVC++. That shall be my next task, as soon as some urgent things are out of the way.

> It was just a technique for generating image of 'plots' that involve showing a value for (almost) every location in the field.

I understand.

> > 2. Is there a simple way to transform a 3D plot into a 2D plot for subsequent printing via your method?
> I suppose it could be done, but the code for doing so would have to be new, and wouldn't be a direct application of what I've coded here.

thanks for your answer, my question is misplaced, I shall start a new thread altogether.

thanks acer, I'll report back if I run into difficulties setting up the 64bit/MSVC++ combo.

First 28 29 30 31 32 33 34 Last Page 30 of 93