Skip to main content
1-Visitor
February 22, 2011
Question

Can the Title of a plot be set by a variable

  • February 22, 2011
  • 3 replies
  • 6118 views

Dear all,

Does anyone knows if we can set the titel of a plot with a variable.

Till now I change the plot titel in clicking on the plot area and changing the labels by hand.

I would like to have a solution where the label for the plot title is set by a variable without having to click on the plot area

Thank you

3 replies

23-Emerald V
February 22, 2011

Patrice Bujard wrote:

Dear all,

Does anyone knows if we can set the titel of a plot with a variable.

Till now I change the plot titel in clicking on the plot area and changing the labels by hand.

I would like to have a solution where the label for the plot title is set by a variable without having to click on the plot area

There's no direct way, AFAIK (don't know about M15 or Prime), but there are a couple of 'tricks' that you can use. Essentially, you define your title variable (:=), evaluate it (=) and then place the evaluated region on top of the plot. You can play around with using a different Math Style and a white font to make the variable 'invisible' or just put a 'white' region on top of the variable name. Won't work for the y-axis title.

You could also use a 3D plot component (inserted as an object not from the menu/toolbar) and use VBScript to modify the title attributes.

See attached worksheet for examples.

Stuart

19-Tanzanite
February 22, 2011

In additoin to Stuart's suggestions, there is one other approach. I have posted this worksheet (or an earlier version of it) before, but it didn't make it over from the old Collaboratory. It uses label components as titles.

23-Emerald V
February 22, 2011

Richard Jackson wrote:

In additoin to Stuart's suggestions, there is one other approach. I have posted this worksheet (or an earlier version of it) before, but it didn't make it over from the old Collaboratory. It uses label components as titles.

I'd forgotten about that one, Richard. Sorry.

However, as partial compensation, it might be worth pointing out that if somebody likes it enough then they can right click on the component, choose 'Export as Component', save it as an .mcm file, copy it to the MCM folder in their Mathcad installation, then double-click it to register it (although I had to browse for mgmreg.exe after double-clicking - I also did it by double-click mgmreg.exe and then browsing to the component). This will (should) make the component directly available from the Insert Component wizard.

Stuart

19-Tanzanite
February 23, 2011
I'd forgotten about that one, Richard. Sorry.

What? You can't remember absolutely everything that was posted on the Collab, including stuff that's over five years old? You must try harder!

http://communities.ptc.com/servlet/JiveServlet/showImage/38-1286-15586/Get+on+with+it!.gif

1-Visitor
February 22, 2011

Another method. I have embedded an Excel component and passed the text string to it.

The one advantage this has is the format of the title can be edited in Excel and you can pass title to each of the axis.

Mike

23-Emerald V
February 22, 2011

Mike Armstrong wrote:

Another method. I have embedded an Excel component and passed the text string to it.

The one advantage this has is the format of the title can be edited in Excel and you can pass title to each of the axis.

Mike

And that's one of the reasons why I've advocated both worksheet-level control of plot component attributes and quote-less formattable strings.

Stuart

eg,

On 2/26/2005 3:57:09 AM, Stuart Bruff wrote:
...

would also give a method for introducing some of the other functionality that people have requested from time to time.

eg, I would like a plot to return its image and allow the user to set it's size or position.

If you just want to display a plot, use the same process as now.

If you want to manipulate it, then treat it like a component and allow it return a value to a Mathcad variable.

plt:=<>

This would return (a pointer to, whatever) that specific plot and allow the user to access the Mathcad-provided properties, such a JPG image of the plot, or it's extent, etc.

img:=[plt]image
xvals:=[plt]xvals[0 - this would return the x axis values corresonding to the first 'trace'.

Setting parameters could be done using named parameters in the component parameter input place holder, something along the lines of:

plt:=<>
<>

Of course, I'd like a functional equivalent of the plot component, so I can manipulate plots without necessarily having to display them.

plt:=plot2D(mydata,xlen:=400,ylen:=300,title:="My 2D Plot")
WRITEBMP("My Plot File"):=[plt]image

where mydata is a structure (eg, nested array) giving the plot's x and y data.


or from thread http://collab.mathsoft.com/read?88340,12 - Aug 06

[edited message to address ambiguity in original - it should refer to strings and not specifically text regions; change higlighted]

Whilst Mathcad's string
text handling allows the user to handle a large range of tasks, I find that it suffers from some deficiencies in use.

1. String wrapping: A large string has the same display problem that a large maths expression has - it doesn't wrap at the right margin. This makes it difficult to examine the string and gives extraneous pages when printing a worksheet (unless 'single page width' is selected, of course).

2. Double Quote: The double quote string delimiters can be distracting when displaying a string and detract from a 'document' appearance.

3. Fixed Plain Text Font: The string displays in a fixed plain-text font, which is not always suitable for displaying complex textual information, or mixing greek and latin characters.

I would like to see an enhanced string display and entry capability that would allow the user to enter and display multi-line, mixed font text with attributes, and have the ability to turn off display of the double quotes. Given Mathcad's XML based file structure, an HTML type display might prove a convenient of implementing such a facility.

The display region should have (user-selectable)auto push-down, and drag-size handles.

'formatted' strings (or at least as I view them) would be just ordinary strings that contain the formatting tags. The modifications just provide additional functionality, mainly in the display of strings, ie.

1). Active HTML/XML Display, eg:

formatted: x="underlined greek text in red is bold" (or minus the quotes)

or

2). Passive Display (plain text): x="<u>underlined</u> <FONT FACE="Symbol">greek</FONT> text in <FONT COLOR="#FF0000"<red>/FONT> is
<b>bold</b>" (which is what you get now).

Oh, and did I mention:

Conversion of a Mathcad expression to XML and vice versa?

1-Visitor
February 22, 2011

I dislike the way Mathcad handles strings, the double quote string delimiters look horrible and make it virtually impossible to present a results table through Mathcad alone.

The new format for tables in Prime is nice, but I have just noticed it has a major flaw. Results cannot directly be passed to a results table in Prime and therefore the newly implemented feature in only good for defining variables, useless results tables.

Mike