Modifying the contour plot from ksdensity

조회 수: 14 (최근 30일)
J T
J T 2020년 1월 24일
댓글: J T 2020년 1월 28일
Hello,
I am trying to modify the 2D contour figure automatically generated by ksdensity for my bi-variate data.
I used the following lines, where ``data`` is a matrix size of 16000-by-2:
>> ksdensity(data,'PlotFcn','contour');
I used ``gcf``, ``gca``, ``findobj`` to extract the current figure, axis, object, however, I couldn't modify any of the properties I need. For example, setting it to a filled contour ('fill', 'on'), turning off the lines ('Linestyle','none') and increasing the level.
Does anyone know how to do this? Thanks!

채택된 답변

Samatha Aleti
Samatha Aleti 2020년 1월 28일
Hi,
As you are directly plotting using ksdensity function, you may not be able to change properties of plot. Instead of that, you may get the probability density estimate f” (let) using “ksdensity function and then plot separately. By doing this, you can use the plot object to change the properties as you need.
Below is the syntax:
[M,c] = contour( f );
c.LineStyle = '-.' ;
Refer the following documentation links for further details:
  댓글 수: 1
J T
J T 2020년 1월 28일
Hi Samatha,
So I obtained ``f`` from the following command where ``data`` is a two-column matrix (16000-by-2 in my case) and attempted to do what you mentioned above:
[f,x] = ksdensity(data,'function','pdf');
contour(f);
It didn't work because ``f`` is a vector size of (900-by-1), do you know how I could have ``ksdensity`` to return a field that could be passed on for contour plot?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by