nmacsai

240 Reputation

9 Badges

3 years, 306 days

MaplePrimes Activity


These are questions asked by nmacsai

transparent_background_in_plots.mw

Is there a better way to impletment a transparent background when genereating plots?

Here I generate a plot with a yellow background.

plot(sin(x), x = 0 .. 4*Pi, background = yellow);


I want the background to be completely transparent instead of yellow.

plot(sin(x), x = 0 .. 4*Pi, background = none);

Error, (in plot) Unable to find image file, none

none is not an accepted color, so an error is returned. Is there such a color as "clear" that is fully transparent? Is there a better way to impletment a transparent background when genereating plots?

I upgraded to Maple 2022 and some of my old sheets from Maple 2021 don't work anymore. When I plot a histogram with a legend I get an error saying: Error, invalid input: Statistics:-Histogram expects value for keyword parameter legend to be of type list, but received data set 1.

OK so maybe Histogram changed in 2022 although I didn't think it did. I ran it in Maple 2021 and I received no such error message. I chose to comply with the error message and the plot is output without an error message, however the legend labels carry extra characters I don't want to be there.  My attempt at a solution was to first use square brackets to make the object a list, then use the typeset command to typeset the label.  Strangely, the typeset command was not recognized.

What am I doing wrong? All I want is to plot a histogram with a legend labelled by a string which I have done many times in the past. I have attached below, a maplesheet which explicitly shows the problematic behaviour.

Thanks,
N

restart

NULL

with(Statistics)

with(LinearAlgebra)``

with(plots)``

NULL

NULL

Define Random Variable

X := RandomVariable(Normal(1, 2))

_R

(1)

Sample that variable and plot a histogram.

s := Sample(X, 1000)

NULL

Maple 2022 as opposed to Maple 2021 does not consider this a valid way to define the legend. It want's it defined in a list as requested in the pink error message.

Histogram(s, legend = "data set 1")

Error, invalid input: Statistics:-Histogram expects value for keyword parameter legend to be of type list, but received data set 1

 

NULL

NULL

Maple 2022 as opposed to Maple 2021 does not consider this a valid way to define the legend. It works fine in Maple 2021. Maple 2022, want's it defined in a list. This works but, the square brackets and quotation marks appear when I don't want them to. The legend shouldn't have these extra quotations and brackets, just the desired name.

Histogram(s, legend = ["data set 1"], size = [300, 300])

 

I tried the typeset command. It doesn't seem to be recognized anymore.

 

Histogram(s, legend = [typeset("data set 1")], size = [300, 300])

 

What am I doing wrong? All I want is to plot a histogram with a legend labelled by a string.   

Download legend_as_list.mw

I am using GenerateMatrix to construct a matrix out of a set of 6 equations with 6 variables.  The output of Generate Matrix is not sorted correctly.  Where am I going wrong? Is this a bug?

restart

NULL``

with(LinearAlgebra)

NULL

NULL

The command GenerateMatrix is not sorting my set of equations properly.

NULL

NULL

Define a set of 6 equations.

equation_set := [5964.000000-770.0000000*T__1+750.0000000*T__2 = 0, 20*T[1]-770.0000000*T[2]+750.0000000*T[3]+100.0000000 = 0, 20*T[2]-770.0000000*T[3]+750.0000000*T[4]+100.0000000 = 0, 20*T[3]-770.0000000*T[4]+750.0000000*T[5]+100.0000000 = 0, 20*T[4]-770.0000000*T[5]+750.0000000*T[6]+100.0000000 = 0, 5900.787944-770.0000000*T[6]+750.0000000*T[5] = 0]

[5964.000000-770.0000000*T__1+750.0000000*T__2 = 0, 20*T[1]-770.0000000*T[2]+750.0000000*T[3]+100.0000000 = 0, 20*T[2]-770.0000000*T[3]+750.0000000*T[4]+100.0000000 = 0, 20*T[3]-770.0000000*T[4]+750.0000000*T[5]+100.0000000 = 0, 20*T[4]-770.0000000*T[5]+750.0000000*T[6]+100.0000000 = 0, 5900.787944-770.0000000*T[6]+750.0000000*T[5] = 0]

(1)

NULL

NULL

NULL

This is what each one looks like individually.

equation_set[1]

5964.000000-770.0000000*T__1+750.0000000*T__2 = 0

(2)

equation_set[2]

20*T[1]-770.0000000*T[2]+750.0000000*T[3]+100.0000000 = 0

(3)

equation_set[3]

20*T[2]-770.0000000*T[3]+750.0000000*T[4]+100.0000000 = 0

(4)

equation_set[4]

20*T[3]-770.0000000*T[4]+750.0000000*T[5]+100.0000000 = 0

(5)

equation_set[5]

20*T[4]-770.0000000*T[5]+750.0000000*T[6]+100.0000000 = 0

(6)

equation_set[6]

5900.787944-770.0000000*T[6]+750.0000000*T[5] = 0

(7)

NULL

The variables used in the above set of equations.

variables_set := [T[1], T[2], T[3], T[4], T[5], T[6]]

[T[1], T[2], T[3], T[4], T[5], T[6]]

(8)

variables_set[1]

T[1]

(9)

A, b := GenerateMatrix(equation_set, variables_set)

Matrix(%id = 36893490238808803916), Vector[column](%id = 36893490238808803796)

(10)

This output seems wrong because a row of zeros appears in A``.  The first entry of the column vector contains the full equation. Thus, it seems GenerateMatrix didn't sort the set of equation properly.  I tried re-writing the  offending equation  as 5964.000000-770.0000000*T__1+750.0000000*T__2 = 0,but maple just changes it back on evaluation.NULL


 I think the output should look like:


A, b := Matrix(6, 6, {(1, 1) = -770.0000000, (1, 2) = 750.0000000, (1, 3) = 0, (1, 4) = 0, (1, 5) = 0, (1, 6) = 0, (2, 1) = 20, (2, 2) = -770.0000000, (2, 3) = 750.0000000, (2, 4) = 0, (2, 5) = 0, (2, 6) = 0, (3, 1) = 0, (3, 2) = 20, (3, 3) = -770.0000000, (3, 4) = 750.0000000, (3, 5) = 0, (3, 6) = 0, (4, 1) = 0, (4, 2) = 0, (4, 3) = 20, (4, 4) = -770.0000000, (4, 5) = 750.0000000, (4, 6) = 0, (5, 1) = 0, (5, 2) = 0, (5, 3) = 0, (5, 4) = 20, (5, 5) = -770.0000000, (5, 6) = 750.0000000, (6, 1) = 0, (6, 2) = 0, (6, 3) = 0, (6, 4) = 0, (6, 5) = 750.0000000, (6, 6) = -770.0000000}), Vector(6, {(1) = -5964.000000, (2) = -100.0000000, (3) = -100.0000000, (4) = -100.0000000, (5) = -100.0000000, (6) = -5900.787944})

NULL

I rename the matrix and column vector and use LinearSolve to find a solution for T.

AA := Matrix(6, 6, {(1, 1) = -770.0000000, (1, 2) = 750.0000000, (1, 3) = 0, (1, 4) = 0, (1, 5) = 0, (1, 6) = 0, (2, 1) = 20, (2, 2) = -770.0000000, (2, 3) = 750.0000000, (2, 4) = 0, (2, 5) = 0, (2, 6) = 0, (3, 1) = 0, (3, 2) = 20, (3, 3) = -770.0000000, (3, 4) = 750.0000000, (3, 5) = 0, (3, 6) = 0, (4, 1) = 0, (4, 2) = 0, (4, 3) = 20, (4, 4) = -770.0000000, (4, 5) = 750.0000000, (4, 6) = 0, (5, 1) = 0, (5, 2) = 0, (5, 3) = 0, (5, 4) = 20, (5, 5) = -770.0000000, (5, 6) = 750.0000000, (6, 1) = 0, (6, 2) = 0, (6, 3) = 0, (6, 4) = 0, (6, 5) = 750.0000000, (6, 6) = -770.0000000})

Matrix(%id = 36893490238866723772)

(11)

``

bb := Vector(6, {(1) = -5964.000000, (2) = -100.0000000, (3) = -100.0000000, (4) = -100.0000000, (5) = -100.0000000, (6) = -5900.787944})

Vector[column](%id = 36893490238885708252)

(12)

NULL

NULL

T := LinearSolve(AA, bb)

Vector[column](%id = 36893490238857651132)

(13)

NULL

Download GenerateMatrix_Improper_Sorting.mw

How do I use ErrorPlots to put error bars on my scatter plot of data, AT THE LOCATION OF THE SCATTER PLOT DATA POINT? Below I write an example demonstrating how I plot the data and error bars using ErrorPlots.  When I use display to combine plots you clearly see that the errorbars are not on the scatter plot data points.  How do I give ErrorPlots, the x-y locations of the data points, so it knows to print the error bars on the location of the data points?  Is there a better approach to putting horizontal and vertical error bars onto scatter plot data?

restart

NULL

Is there a direct way to have the int command return the anti-derivative plus an arbitrary constant of integration? I am imagining the process to look like:
int(f(x), x) = F(x)+c1

NULL

Consider the integral of f(x)=x.f := x

x

(1)

Int(f, x); int(f, x)

(1/2)*x^2

(2)

Notice that the output has no intregration constant or the constant has been assigned the value of zero and is not displayed in the output.

Maple 2021 Help states, "Indefinite integration  is performed if the second argument x is a name. Note that no constant of integration appears in the result. Definite integration is performed if the second argument is of the form x=a..b where a and b are the endpoints of the interval of integration."

I'd like Maple to output the anti-derivative plus an arbitrary constant in the same way dsolve outputs a general solution of an ode with arbitrary constants. My first work around was to just use dsolve.  

There is a sense in which performing an integration is equivalent to solving an ode:
diff(h(x), x) = g(x); int(diff(h(x), x), x) = int(g(x), x); h(x) = int(g(x), x)+c1; h(x) = G(x)+c2
    

Is there a way to force int to output arbitrary constants of integration or should I stick to just using dsolve if I want that effect?

Download constants_of_integration_int_output.mw

4 5 6 7 Page 6 of 7