1

I want to show two different data in the same figure and I want to show densities of each data with colors. I used below code:

scatter(xm,ym,[],c/(max(c)),'filled','d')
hold on
scatter(x,y, [], dens,'filled','d')

but it only shows data (x,y) colored and data xm and ym are all red. When I use scatter(xm,ym,[],c/(max(c)),'filled','d') without using scatter(x,y, [], dens,'filled','d'), it shows xm and ym data colored.But when I use both scatters with a hold on between them, the error I mentioned occurs. How can I solve the problem? could anyone help?

Sonia Sohi
  • 117
  • 1
  • 12
  • This is a scaling problem, the 2 data sets are probably at different scales causing the second to seem constant. What do you want your output to look like exactly? – Stack Player Apr 14 '17 at 20:46
  • Yes, they have different scales. I want the first data (which have been used in the first scatter) to be shown as a background field which it's color in each position shows the amount of it in that position(for example if a region is red, it means that c is high in that region), and also I want the second data to be shown with different colours in position related to them. Is it clear now? @StackPlayer – Sonia Sohi Apr 14 '17 at 21:05

1 Answers1

0

One clean option is to use 2 subplots, but it will not give you neatly the overlap you are looking for.

Another trick is to scale the background data values to 0-1, and the second data values to 1-2. And then plot them the way you are doing it. (this will distinguish the colors, and will keep them readable since the ranges are both of size 1).

Stack Player
  • 1,470
  • 2
  • 18
  • 32