Multiple color plots / colorbars on a single axes

3 visualizzazioni (ultimi 30 giorni)
Hi,
I am trying to make a tool to easily visualize outputs from a simulation.
With that in mind, I would like to be able to make slices in the 3D domain for various fields (e.g. velocity, current,...) and still provide flexibility for the user.
Currently, one can call a plot function that will create a figure and make a slice plot at the desired slices for one field:
uni.plot('newfigure','slice','yslice',0,'variable','jz','color','jet','colorposition','left')
where uni is an object of my class, and the various inputs parameters includ one that specifies the variable to plot (here, jz).
Let's call this plot, plot 1.
Now the user can make a second plot, plot 2 on top of the previous one
uni.plot('slice','zslice',0,'variable','ux','color','jet','colorposition','right')
For simplicity, I had decided to create a new axes for each new plot.
However, because the new axes of plot 2 appear on top of the one from plot 1, it does not look like they are plot on the same figure but on top of each other (obviously).
This can be seen in this figure:
To overcome that, I thought, let's just copy the slice from plot 2 into the axes from plot 1 using copyobj and then I can delete the plot that is on top.
This works to some extent but as you can see below, the second slice that was done (that was on top) is now merged in the first axes but its color automatically adapted to the colorbar of plot 1.
My question is then the following:
How to keep the second slice plot "attached" to its own colorbar?
Note that I cannot use the same colorbar because:
1) The variables are separated by several orders of magnitude
2) I would like the user to be able to specify the colormap for each plot they make.
If my approach is wrong, is there any alternative way to treat the problem I presented here?
Best,
Alexandre

Risposta accettata

Bjorn Gustavsson
Bjorn Gustavsson il 18 Ott 2019
There are some contributions on the file exchange that deals with this. I thik this is one: colormat-and-colorbar-utilities
You might find some others that suits your task better.
HTH
  1 Commento
De Spiegeleer Alexandre
De Spiegeleer Alexandre il 18 Ott 2019
Hej björn,
Thanks for the link.
Turns out I found what I needed in there.
I am using the cmapping function to create the RGB of my color data before I copy the slice onto plot 1.
And, after I copied the slice, I set the CData value to the RGB.
I works like a charm, thanks :)
I still wonder why they don't link the colormap to the data rather than to the axes ... but well there is a work around.
Cheers,
Alex.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Colormaps in Help Center e File Exchange

Prodotti


Release

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by