getting user input in title and legend

4 views (last 30 days)
mat geek
mat geek on 22 Apr 2019
Answered: Adam Danz on 22 Apr 2019
the code is you want to create a graph showing the relationship of an ideal gas between pressure (P) and temperature (T).
the first 2 are Nitrogen, and oxygen the third will be ser input of gas. I created 2 figures. Figure (1) for all plots on the same axis, and the figure 2 is for sublpot of each gas.And ask the user to input the gas name. But how can I input the gas name from the user to the legend or title.
I hope that was clear.

Answers (2)

Star Strider
Star Strider on 22 Apr 2019
I would use the inputdlg (link) function. You can also use input.
  3 Comments
Star Strider
Star Strider on 22 Apr 2019
mat geek’s Answer moved here:
How can You do that and place it in title or legend?
Star Strider
Star Strider on 22 Apr 2019
Use that to get the user input.
Then use the sprintf function to print it in the title or legend.

Sign in to comment.


Adam Danz
Adam Danz on 22 Apr 2019
In addition to Star Strider's method, the user can directly edit titles and legend strings by selecting them on the figure itself (the user won't be prompted and will have to know how to edit these objects).
Just click on the white arrow, then double-click the title and/or legend to change the string.
190422 174146-Figure 1.jpg

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!