필터 지우기
필터 지우기

How to create a plot with Slider and UI Input

조회 수: 187 (최근 30일)
Harish Rajan
Harish Rajan 2020년 6월 12일
댓글: Gary Gorman 2022년 10월 30일
Hello,
I am trying to create a interactive plot where the user has to select a point in the plot however the datasaet I am dealing with has large number of point (~1000) so the graph becomes cluttered. Thus i wanted to implement a slider where the user can chose the required number of points first which would update the graph automatically and when the user is satisfied they can chose the point using ginput. I have attached a sample snippet of the code here.
clc
clear variables
close all
figure()
x=1:100;
y=x.^2;
% The slider has to be implemented here so user can decide the number of points to be displayed,
% the graph has to update in real time to the responses of the slider.
plot(x,y,'o','color','r')
xlabel('x')
ylabel('y')
[req_point,~]=ginput(1);
point_ind=round(req_point);

답변 (1개)

Harsha Priya Daggubati
Harsha Priya Daggubati 2020년 6월 16일
Hi,
I guess the following link helps you get an idea on how to use a slider to control your plot. You can write code such that the callback associated with slider, helps to choose a suitable number of points to be displayed on the slider or you can modify the range of values of X and Y axes, to reduce the data density.
  댓글 수: 2
Harish Rajan
Harish Rajan 2020년 6월 16일
Thank You
Gary Gorman
Gary Gorman 2022년 10월 30일
Harish, the linked demo requires a bunch of toolboxes. Is there a slider demo for interactive plots that doesnt have a whole bunch of tool boxes?

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

카테고리

Help CenterFile Exchange에서 Specifying Target for Graphics Output에 대해 자세히 알아보기

태그

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by