Is it possible to use gscatter in matlab app designer?
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi! :)
I am watching some videos of matlab on the internet. In the videos a man is applying just x and y axis plots and I think they dont look that interesting .
Does anybody knows how or whether it is possible to use gscatter plots in matlab app designer. I have matlab 2018b release.
0 comentarios
Respuestas (2)
dpb
el 22 de Oct. de 2023
Editada: dpb
el 22 de Oct. de 2023
Works with R2021b; I do not know at what release the support for uiaxes was introduced; used to be able to get to the doc for earlier releases, now I don't see any way to get there any more...nothing was mentioned in R2018b release notes but that doesn't mean too much for small incremental improvement.
Current doc shows the syntax and explicitly mentions ax or uiaxes object handle; if your release doesn't show that, then it won't work and nothing you can do about it other than either upgrade to a release that does support it or generate the scatter plot by groups a group at a time with regular scatter() plot and grouping variables. One could probably get clever and do it in a one-liner with varfun if your data are in a table or certainly with findgroups and splitapply. "More than one way to skin a cat..."
load carsmall
whos
[g,id]=findgroups(Model_Year);
hAx=axes; hold(hAx,'on')
splitapply(@(x,y)scatter(x,y,'filled'),Displacement,Horsepower,g)
legend(hAx,"Model Year "+string(1900+id),'location','northwest')
xlabel('Displacement'), ylabel('Horsepower')
I wasn't able to get varfun() to work with scatter() for some reason...not at all clear why it shouldn't work similarly as does splitapply() above.
7 comentarios
Dyuman Joshi
el 26 de Oct. de 2023
Walter Roberson
el 26 de Oct. de 2023
Mathworks only keeps the latest 5 years on public-facing sites. We discussed this with them, and they said that it was taking significant resources to keep updating the old documentation to match changes in their search engine.
They had offered to make older releases available as PDFs, but they have not done that.
Walter Roberson
el 22 de Oct. de 2023
gcf() and newplot() can only "see" figures and axes that have their HandleVisibility set 'on'
uifigures default to HandleVisibility off -- and in your release, the HandleVisibility cannot be turned on for uifigure() so it is not possible to "fool" gcf into looking for uifigures by turning the handle visibility on.
R2019b is the first release that supported passing an axes handle to gscatter
In your R2018b release what you need to do is allow gscatter to plot into a traditional figure with traditional axes, and then copyobj() the contents into your uiaxes and then delete the traditional figure . This will cause the traditional figure to flash into existence and be drawn into before disappearing again with the contents showing up in the uiaxes.
This was not a great situation, but it is what was available 5 years ago.
3 comentarios
Walter Roberson
el 23 de Oct. de 2023
Good point about the possibility of turning visbility off.
There are some cases where you must let an axes render before it has correct / consistent information, but I think in this particular case it would not be a problem.
You can use scatter, but it takes more work -- either calling scatter() once for each group or else fudging the legend() entries
gscatter(1:10, rand(10,5), randi(3,1,10))
dpb
el 23 de Oct. de 2023
Editada: dpb
el 24 de Oct. de 2023
I'm pretty sure given the limitations I'd prefer the above illustration with @splitapply to do the grouping and plotting directly into the uiaxes over the workaround of plotting to a normal axis and then copyobj(). As the example shows, there's no "fudging of legend entries" required...
That does presume, of course, that scatter and legend had been updated to allow a uiaxes handle by the given release.
Ver también
Categorías
Más información sobre Develop uifigure-Based Apps en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!