acer

32323 Reputation

29 Badges

19 years, 316 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

Why can't you simply evaluate at the given numeric values for t?

Show us how you produced the plot, and we can show you how to do that.

That would be more accurate and far less error prone than using crude mouse-pointer position.

You can upload and attach a worksheet using the green up-arrow in the Mapleprimes editor.

What is your reason for not explicitly telling us what it is that you do need?

@vs140580 For 2D plots you can pass the option,

   legendstyle=[location=right]

etc, to the plotting command or to the plots:-display command for your case of a merged point-plot and a curve-plot.

For the 3D case there is no direct facility to place a caption (or title) on either side, and legends aren't available. I can, however, think of a few ways to mimic the effect. One way is to use a textplot, placed carefully according to a fixed orientation (without further manual rotations). Another is to use Tabulate to place a close 2D plot containing only the legend (although that cannot then be exported as a single image).

But I am not going to do either of those unless you state explicitly and believably what is your final goal. You have made ten (!) followup Replies in this thread, many of them revisions or augmentations of your goal. I don't believe that your latest Reply was your final goal.

@vs140580 The following behaves for me in Maple 2020.2. The color symbols also survive export of the plot to an image file.

The attachment shows how the caption can be stacked (multi-line), or a single space line (seen below).

regr_3d2d_4.mw

 

Note: The techniques from this old Post don't work completely properly in my Maple 2020.2, since when I right-click on the plots to export the symbols in the plot (not the caption!) vanish. The above attachment has a tweak to the approach which fixes that (for me, at least).

@vs140580 

Uncomment the legend for the fitted curve, if you want.

F2d:=Statistics:-LinearFit(a*x, pts[..,[1,2]], x):
plots:-display(
  plot(pts[..,[1,2]],
       style=point, color=red,
       legend="my data points",
       symbol=solidbox, symbolsize=15),
  plot(F2d,
       x=min(pts[..,1])..max(pts[..,1])
#      , legend="fitted curve"
       ),
  labels=[x,y], axes=box);

I believe that you could figure this out after reading the Help pages on the links I included.

@vs140580 You can specify the used symbol, and its symbolsize, and its color. (If you look at the linked Help page I gave before you would see all these options described.)

F2d:=Statistics:-LinearFit(a*x, pts[..,[1,2]], x):
plots:-display(
  plot(pts[..,[1,2]],
       style=point, color=red,
       symbol=solidbox, symbolsize=15),
  plot(F2d,
       x=min(pts[..,1])..max(pts[..,1])),
  labels=[x,y], axes=box);

I don't understand what you mean by having a legend for such points. What would it show!?

For fun, as an alternative to regression in 3D is to interpolate. (The fitted curve from the previous regression doesn't pass through the points exactly, although the plane surface is optimized to reduce the error. The following interpolated curve passes through the data points.)

Ip := Interpolation:-RadialBasisFunctionInterpolation(pts[..,1..2],pts[..,3]):
plots:-display(
  plots:-pointplot3d(pts,color=red,symbol=solidsphere,symbolsize=12),
  plot3d(Ip(x,y),
       x=min(pts[..,1])..max(pts[..,1]),
       y=min(pts[..,2])..max(pts[..,2]),
       color=gray),
  tickmarks=[4,4,3], size=[600,600],
  labels=[x,y,""], lightmodel=none, axes=box);

regr_3d2d_2.mw

@vs140580 You can adjust the overall plot size using the size option, and one way to adjust the tickmarks is to use the tickmarks option.

For example, using that data in pts,

plots:-display(
  plots:-pointplot3d(pts,color=red,symbol=solidsphere,symbolsize=12),
  plot3d(F3d,
       x=min(pts[..,1])..max(pts[..,1]),
       y=min(pts[..,2])..max(pts[..,2]),
       color=gray,style=surface,transparency=0.1),
  tickmarks=[4,4,3],
  labels=[x,y,""], lightmodel=none, axes=box, size=[600,600]);

And using your latest Reply's data, that same command produces this:

I believe that you could figure this out after reading the Help pages on the links I included.

Below I asked you whether you are trying to perform regression on this data. Are you?

Please don't post that as a separate Question thread. Duplicates get flagged as such and may be deleted.

@vs140580 Your goals are unclear. Is there a reason why you cannot state exactly what you are trying to accomplish!?

pts:= Matrix([[19.8,12, 1.62],[24.7,14, 1.2],
                   [26, 16, 1.25],[35.1,20, 0.84],
                   [37.8,20.83,0.74],[10.8,9, 3.98],
                   [16.1,12, 2.46],[38.3,18, 0.52],
                   [24.5,16, 1.42],[15.8,11, 2.35],
                   [28.2,17.8, 1.19],[56.8,27, 0.37],
                   [25.4,17, 1.34],[29.3,18.1,1.12]]):

I don't see how the formula f that you gave relates to the given data points. Are you trying to plot them together?

f := 72.7*x-24.5*y:
plots:-display(
  plot(pts[..,[1,2]],style=point),
  plot([solve(f,y)],
       x=min(pts[..,1])..max(pts[..,1])),
  labels=[x,y], axes=box);

Was your formula for f just an example? Are you trying to do (linear) regression/curvefitting of the x-y points in your data, ie. regression using the first two columns?

F:=Statistics:-LinearFit(a*x, pts[..,[1,2]], x);

plots:-display(
  plot(pts[..,[1,2]],style=point),
  plot(F,
       x=min(pts[..,1])..max(pts[..,1])),
  labels=[x,y], axes=box);

@mmcdara I suspect that the line with,

    if dnew < 5 then  return i 

is there to find the (first, if any) existing point that is within sqrt(5) distance from the clicked point.That would contrast with your approach to accept always the closest existing point, regardless.

And since a table is a mutable data structure you can add/remove from it with less garbage production. Augmenting a list (or subsop'ing with NULL) creates a new list each time, and the old list becomes collectible garbage. Just my guess, as to motive. As you suggest, with a very small number of points such considerations might have small impact. (...and a collectible/transient structure might be needed for sending to the plot command, anyway.)

@vs140580 Do you mean something like these?

restart;

f := 72.7*x-24.5*y;

plots:-implicitplot(f, x=-2..2, y=-5..5,
                    rangeasview, labels=[x,y], axes=box);

plot([solve(f,y)], x=-2..2,
     view=-5..5, labels=[x,y], axes=box);

@Idontcare I really think that you should not use the approach of entering 3 or more expressions separated by =, in 2D Input mode.

The 2D Parser turns something that looks like this,

   -a*b + a*c = -a*b + a*c = a*(c - b)

into the following (Maple plaintext code),

   -a*b + a*c = -a*b + a*c and -a*b + a*c = a*(c - b)

That lowercase and makes Maple test each of those equations in the same way that evalb works, including this second one,

   -a*b + a*c = a*(c - b)

and that returns false because the lhs and rhs are not numeric and also not the identically same symbolic expression. They are the same mathematically, but not structurally. That's why evalb is not the appropriate mechanism for you. See my examples above in my original Answer.

I think that entering such conjoined multiple `=` statements in 2D Input mode is a very poor approach. I think that you would be much, much better off using the approach of assigning single equations (two expressions on either side of an = sign) to various new variables, and then testing them in one of the successful ways that I showed above in my original Answer.

In the long run, you will be much better off learning commands, and learning Maple as a plaintext programming language. I also suggest you consider using 1D Maple (plaintext) notation inside Execution Groups of a Worksheet instead of the (default, sigh) 2D Input mode in a Document.

@mmcdara You're welcome.

Here is a slight revision in which the radio-buttons both set a value of a module local, which denotes the adding/removing mode's status (ie. a boolean). One advantage of this approach is that it makes it easier to test the action code separately from any button/plot clicking. In some advanced applications that can sometimes be convenient.

sketch_ac2.mw

Let us know if you plan on creating a procedure that build/inserts this whole assembly, using DocumentTools:-Layout/Components. In that case there are a few tricks that make it possible to embed multiple instances of the application (on the fly in the same worksheet) which each utilize the same Bez module runtime but whose buttons/plots act independently of each other.

ps. I didn't mention that a full sort is higher computational complexity than necessary for determination of the position in the point-list of the closest match. I'm sure you know that already, and only wanted a short snip of code that made the example work. The embedded component programming is the question here.

@tomleslie You wrote, "Unfortunately the 'size' option is not available for 3D plots:-("

But support for the size option for 3D plots was introduced in Maple 2020. The plot3d and plots:-display command now accept it.

 

@Idontcare I can't say for sure because you still haven't shown us your explicit example  so I don't know what exact commands you're using and how.

You can upload and attach a worksheet here using the green up-arrow in the Mapleprimes editor.

First 129 130 131 132 133 134 135 Last Page 131 of 591