matlab中如何调用函数的magnify如何使用

Controlling plot data-tips | Undocumented Matlab
Charting Matlab’s unsupported hidden underbellyHello there! If you are new here, you might want to
for updates on Undocumented Matlab topics.Plot
are a great visualization aid for Matlab plots. They enable users to interactively click on a plot location and see a tool-tip that contains the clicked location’s coordinates. The displayed tooltip text is even customizable using documented properties of the
object.plot data tipsA client has recently asked me to automatically display an attached data-tip to the last data point of a plotted time series of values. The idea was to immediately see what the latest value of the data series is.Unfortunately, the official documentation clearly says that:You place data tips only by clicking data objects on graphs. You cannot place them programmatically (by executing code to position a data cursor).Well, this has never stopped us before, has it?Creating new data tipsUnder the hood, data tips use a data-cursor mode, which shares many similarities in behavior and programming code with the other plot modes (zoom, pan, , etc.). At any one time, only a single such mode can be active in any figure window (this is a known limitation of the design). The code itself it actually quite complex and handles numerous edge-cases. Understanding it by simply reading the code (under %matlabroot%\toolbox\matlab\graphics\) is actually pretty difficult. A much easier way to understand the programming flow is to liberally distribute breakpoints (start in datacursormode.m) and interactively activate the functionality, then debug the code step-by-step.Luckily, it turns out that the code to create a new data-tip is actually quite simple: first get the data-cursor mode object, then create a new data tip using the mode’s createDatatip() method, update some data-tip properties and finally update the data-tip’s position:% First plot the data
hLine = plot(xdata, ydata);
% First get the figure's data-cursor mode, activate it, and set some of its properties
cursorMode = datacursormode(gcf);
set(cursorMode, 'enable','on', 'UpdateFcn',@setDataTipTxt, 'NewDataCursorOnClick',false);
% Note: the optional @setDataTipTxt is used to customize the data-tip's appearance
% Note: the following code was adapted from %matlabroot%\toolbox\matlab\graphics\datacursormode.m
% Create a new data tip
hTarget = handle(hLine);
hDatatip = cursorMode.createDatatip(hTarget);
% Create a copy of the context menu for the datatip:
set(hDatatip,'UIContextMenu',get(cursorMode,'UIContextMenu'));
set(hDatatip,'HandleVisibility','off');
set(hDatatip,'Host',hTarget);
set(hDatatip,'ViewStyle','datatip');
% Set the data-tip orientation to top-right rather than auto
set(hDatatip,'OrientationMode','manual');
set(hDatatip,'Orientation','top-right');
% Update the datatip marker appearance
set(hDatatip, 'MarkerSize',5, 'MarkerFaceColor','none', ...
'MarkerEdgeColor','k', 'Marker','o', 'HitTest','off');
% Move the datatip to the right-most data vertex point
position = [xdata(end),ydata(end),1; xdata(end),ydata(end),-1];
update(hDatatip, position);Note: If you don’t like messing with the code, consider using Tim Farajian’s
utility, which basically does all this behind the scenes. It is much easier to use as a stand-alone utility, although it does not give you the flexiblility with all the data-tip properties as in the code above.Updating an existing data tipTo modify the appearance of a data-tip, we first need to get access to the hDatatip object that we created earlier, either programmatically, or interactively (or both). Since we can access pre-stored handles only of programmatically-created (not interactively-created) data-tips, we need to use a different method. There are actually two ways to do this:The basic way is to search the relevant axes for objects that have Tag=’DataTipMarker’. For each data-tip, we will get two such handles: one for the marker (Type=’line’) and the other for the text box tooltip (Type=’text’). We can use these to update (for example) the marker size, and the text’s font, border and colors.A better way is to access the graphics.datatip object itself. This can be done using two hidden properties of the datacursormode object:% Get the list of all data-tips in the current figure
&& cursorMode = datacursormode(gcf)
cursorMode =
graphics.datacursormanager
&& cursorMode.DataCursors
graphics.datatip: 2-by-1
&& cursorMode.CurrentDataCursor
graphics.datatip
&& cursorMode.CurrentDataCursor.get
Annotation: [1x1 hg.Annotation]
DisplayName: ''
HitTestArea: 'off'
BeingDeleted: 'off'
ButtonDownFcn: []
Children: [2x1 double]
Clipping: 'on'
CreateFcn: []
DeleteFcn: []
BusyAction: 'queue'
HandleVisibility: 'off'
HitTest: 'off'
Interruptible: 'on'
Parent: 492.
SelectionHighlight: 'on'
Type: 'hggroup'
UserData: []
Selected: 'off'
FontAngle: 'normal'
FontName: 'Helvetica'
FontSize: 8
FontUnits: 'points'
FontWeight: 'normal'
EdgeColor: [0.8 0.8 0.8]
BackgroundColor: [1 1 0.333]
TextColor: [0 0 0]
Marker: 'o'
MarkerSize: 5
MarkerEdgeColor: 'k'
MarkerFaceColor: 'none'
MarkerEraseMode: 'normal'
Draggable: 'on'
String: {'Date: 01/09/11'
'Value: 573.24'}
Visible: 'on'
StringFcn: []
UpdateFcn: []
UIContextMenu: [1x1 uicontextmenu]
Host: [1x1 graph2d.lineseries]
Interpolate: 'off'We can see that the returned graphics.datatip object includes properties of both the text-box and the marker, making it easy to modify. Moreover, we can use its aforementioned update method to move the datatip to a different plot position (see example in the code above). In addition, we can also use the self-explanatory getCursorInfo(), getaxes(), makeCurrent(), movetofront() methods, and a few others.Cursor mode and data-tip propertiesThe graphics.datacursormanager and the graphics.datatip objects have several public properties that we can use:&& cursorMode.get
Enable: 'off'
SnapToDataVertex: 'on'
DisplayStyle: 'datatip'
UpdateFcn: @setDataTipTxt
Figure: [1x1 figure]
&& cursorMode.CurrentDataCursor.get
Annotation: [1x1 hg.Annotation]
DisplayName: ''
HitTestArea: 'off'
... % See the list aboveBoth these objects have plenty of additional hidden properties. You can inspect them using my . Here is a brief list for reference (R2011b):graphics.datacursormanager:CurrentDataCursorDataCursorsDebugDefaultExportVarNameDefaultPanelPositionEnableAxesStackingEnableZStackingExternalListenersHiddenUpdateFcnNewDataCursorOnClickOriginalRendererOriginalRendererModePanelDatatipHandlePanelHandlePanelTextHandleUIContextMenuUIStateZStackMinimumgraphics.datatip:ALimIncludeApplicationDataBehaviorCLimIncludeDataCursorHandleDataManagerHandleDebugDoThrowStartDragEventEmptyArgUpdateFcnEnableAxesStackingEnableZStackingEraseModeEventObjectExternalListenerHandlesHelpTopicKeyHostAxesHostListenerHandlesIncludeRendererInvalidIsDeserializingMarkerHandleMarkerHandleButtonDownFcnOrientationOrientationModeOrientationPropertyListenerOriginalDoubleBufferStatePixelBoundsPointsOffsetPositionSelfListenerHandlesSerializableTextBoxHandleTextBoxHandleButtonDownFcnVersionViewStyleXLimIncludeYLimIncludeZLimIncludeZStackMinimumuistateAs can be seen, if we really want, we can always use the MarkerHandle or TextBoxHandle directly.Deleting data tipsTo delete a specific data-tip, simply call the cursor mode’s removeDataCursor() to delete all data-tips, call its removeAllDataCursors() method:% Delete the current data-tip
cursorMode.removeDataCursor(cursorMode.CurrentDataCursor)
% Delete all data-tips
cursorMode.removeAllDataCursors()Have you used plot data-tips in some nifty way? If so, please share your experience in a
below.p.s. – did you notice that Java was not mentioned anywhere above? Mode managers use pure-Matlab functionality.Related posts: Matlab's standard plot data-tips can be customized to enable dragging, without being limitted to be adjacent to their data-point. ... Plot data brushing can be accessed programmatically using very simple pure-Matlab code... Callback reentrancy is a major problem for frequently-fired events. Luckily, it can easily be solved.... LineSmoothing is a hidden and undocumented plot line property that creates anti-aliased (smooth unpixelized) lines in Matlab plots... This article describes several little-known tips useful for COM / ActiveX programming in Matlab... The plot objects' XLimInclude, YLimInclude, ZLimInclude, ALimInclude and CLimInclude properties are an important feature, that has both functional and performance implications.... Categories: , , , , , Tags: , , , , , & Pingback: Pingback: Leave a Reply
Enclose with " for exact match e.g., "uitable report"
Advanced on-site Matlab training, amazing value - Useful links&&&&& && Recent PostsArchives
';collapsItems['collapsArch-']='
';collapsItems['collapsArch-']='
';collapsItems['collapsArch-']='
';collapsItems['collapsArch-']='
';collapsItems['collapsArch-']='
';collapsItems['collapsArch-']='
';collapsItems['collapsArch-']='
';collapsItems['collapsArch-']='
';collapsItems['collapsArch-']='
';collapsItems['collapsArch-']='
';collapsItems['collapsArch-']='
';collapsItems['collapsArch-']='
';collapsItems['collapsArch-']='
';collapsItems['collapsArch-']='
';collapsItems['collapsArch-']='
';collapsItems['collapsArch-']='
';collapsItems['collapsArch-']='
';collapsItems['collapsArch-']='
';collapsItems['collapsArch-']='
';collapsItems['collapsArch-']='
';collapsItems['collapsArch-']='
';collapsItems['collapsArch-']='
';collapsItems['collapsArch-']='
';collapsItems['collapsArch-']='
';collapsItems['collapsArch-']='
';collapsItems['collapsArch-']='
';collapsItems['collapsArch-']='
';collapsItems['collapsArch-']='
';collapsItems['collapsArch-']='
';collapsItems['collapsArch-']='
';collapsItems['collapsArch-']='
';collapsItems['collapsArch-']='
';collapsItems['collapsArch-']='
';collapsItems['collapsArch-']='
';collapsItems['collapsArch-']='
';collapsItems['collapsArch-']='
';collapsItems['collapsArch-']='
';collapsItems['collapsArch-']='
';collapsItems['collapsArch-']='
';collapsItems['collapsArch-']='
';collapsItems['collapsArch-']='
';collapsItems['collapsArch-']='
';collapsItems['collapsArch-']='
';collapsItems['collapsArch-']='
';collapsItems['collapsArch-']='
';collapsItems['collapsArch-']='
';collapsItems['collapsArch-']='
';collapsItems['collapsArch-']='
';collapsItems['collapsArch-']='
';collapsItems['collapsArch-']='
';collapsItems['collapsArch-']='
';collapsItems['collapsArch-']='
';collapsItems['collapsArch-']='
';collapsItems['collapsArch-']='
';collapsItems['collapsArch-']='
';collapsItems['collapsArch-']='
';collapsItems['collapsArch-']='
';collapsItems['collapsArch-']='
';collapsItems['collapsArch-']='
';collapsItems['collapsArch-']='
';collapsItems['collapsArch-']='
';collapsItems['collapsArch-']='
';collapsItems['collapsArch-']='
';collapsItems['collapsArch-']='
';collapsItems['collapsArch-']='
';collapsItems['collapsArch-']='
';collapsItems['collapsArch-']='
';collapsItems['collapsArch-']='
';collapsItems['collapsArch-']='
';collapsItems['collapsArch-']='
';collapsItems['collapsArch-']='
';collapsItems['collapsArch-']='
';collapsItems['collapsArch-']='
';String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"");}
function createCookie(name,value,days){if(days){var date=new Date();date.setTime(date.getTime()+(days*24*60*60*1000));var expires="; expires="+date.toGMTString();}else{var expires="";}
document.cookie=name+"="+value+expires+"; path=/";}
function readCookie(name){var nameEQ=name+"=";var ca=document.cookie.split(';');for(var i=0;i*/Categories (35) (36) (47) (120) (64) (34) (7) (139) (17) (14) (9) (291) (63) (122) (109) (7) (31) (114) (4) (41) (10) (145) (30): Hi Yair, Assigning the renderer object to all the table columns as follows: for j = 1 : length(cnames3) jTable.getColumnModel.getColum n(j-1).setCellRenderer(cr); end is making my...: You probably figured it out by now, but for future readers: I got this error when trying to display different uitables at the same position.: Hi Yair, Thank you, it’s working perfectly.: You can use DefaultTableModel with dummy column headers (identifiers), and then remove the table header: jTable.setTableHeader([]);: Hi Yair, Thank you for posting this. Is there a way to replace Matlab’s table model with something more renderer-friendly without headers? My headers are included in the...: cute : There is another semi-documented feature of the view: you can link the View property across multiple axes. For example, figure('Units','normalized','O uterPosition',[.10 .10 .80...: A quick follow up on the issue mentioned above. Even though it’s a bit of a dirty fix—which kills some of the flexibility—it appears that blocking editing directly in...: Read this related post: / blog/allocation-performance-ta ke-2: I have. I have sent you by e-mail a MWE showing this behavior.: Yup, that works. Thanks so much, Yair. It’s a pretty awful hack job to achieve sth that I feel should be basic functionality but here we go: % generate data rng(144); xData =...: @Alex – have you actually tried this? I do not think that the cells can be interactively edited after editing has been prevented as in my code.: Hi Yair, to prevent editability of cells, I see in your code that you take two actions (in the subfunction setColumnRenderersEditors): jte.setClickCountToStart(intma x)...: Hello! I’m trying this in matlab r2015a, I got the same problem as Fabian, but the drawnow command does not solve the problem. x_new3= y_new3= z_new3=...Contact Us[转载]matlab画一个局部放大的图中图(总结)
照旧感谢原作者,分享者们,阿门!
以下三种方法,szlqq345喜欢用第一种的。
第一种:magnify是个动态放大镜,固化后可以用tools&edit
plot移动小图,能选取多个局部图,这个方法不错
用法:打开figure图,输入magnify,左键动态选取查看,ctrl+左键固化,也可右键固化,‘&’和‘&’缩放方法范围,‘+’和‘-’缩放放大比例
第二种:用起来也很方便,缺点是只能框选一处,不能选取多个。
美国学者and编写的MasteringMATLAB7上的例子,实现图中图缩放功能,使用了3个函数,这三个函数在附件中,当然也可以到网站去下载。
函数简单介绍:
getn()将get()函数的输出参数简化为单个变量;
getbox()实现矩形区域的选择,并捕捉该区域的横纵标的范围
mmzoom创建一个缩放坐标轴。
试图做了例子,传上来一起分享。
&x = -pi:pi/12:
&y = tan(sin(x)) - sin(tan(x));
&plot(x,y,'--
ro','LineWidth',2,'MarkerEdgeColor','k','MarkerFaceColor','g',
&'MarkerSize',7.5)
&mmzoom&&&&&&
第三种:也可编个小程序,分别在两个图形句柄里画图,可以借鉴下
figure(1);
h2=axes('position',[0 0 1 1]);
x2=0:pi/50:2*
y2=sin(x2);
h3=plot(x2,y2,'b-');
h1=axes('position',[0.3 0.2 0.4 0.4]);
x1=0:pi/50:2*
y1=cos(x1);
h4=plot(x1,y1,'r-');
h=[h3; h4];
str=['大图中的曲线';'小图中的曲线'];
legend(h,str);
以上网友发言只代表其个人观点,不代表新浪网的观点或立场。xdlarge matlab绘图局部放大源码,看清所要关心的
182万源代码下载-
&文件名称: xdlarge
& & & & &&]
&&所属分类:
&&开发工具: MathCAD
&&文件大小: 2 KB
&&上传时间:
&&下载次数: 5
&&提 供 者:
&详细说明:matlab绘图局部放大源码,看清所要关心的部分-matlab drawing enlarged source, see the part to be concerned about
文件列表(点击判断是否您需要的文件,如果是垃圾请在下面评价投诉):
&&xdlarge.m
&[]:很好,推荐下载
&相关搜索:
&输入关键字,在本站182万海量源码库中尽情搜索:
&[] - 详述了Matlab中画图的命令及技巧,针对出现的问题进行了说明和逐一演示。
&[] - 在MATLAB生成的FIG中进行局部放大,
&[] - 随机共振相似度的Matlab计算程序,计算看出输入-输出的相似度S随着噪音的标准差的增大而不断得到改善,直到增大至一饱和值为止。
&[] - Matlab中的四阶龙格库塔法m文件。
&[] - 这个描述的频率细化技术,想使用这样的方法,对密集的地方进行放大。MatLaB中的magnify如何使用_百度知道
MatLaB中的magnify如何使用
据说可以放大图的部分
可是不会用 有会用的吗
提问者采纳
值得说明的是,magnify是一个函数,默认安装中是不存在的,需要额外加载。具体有三步:第一步,下载文件magnify.m下面是我分离的一个文件下载链接:链接: 密码:bcd2或从官网下载:第二步,文件拷贝到工具箱路径把文件放在toolbox路径下,例如:C:\Program Files\MATLAB\R2009b\toolbox\matlab\elfun只要是matlab加载的路径就可以。第三步,更新工具箱在matlab窗口的command window 中运行命令:rehash toolboxcache下面是使用案例:在command window 运行 &ezplot('t')得到在command window 运行 &magnify切换到figure图形窗口按ctrl键,拖动鼠标左键,(也可以不按ctrl键,拖动鼠标右键)就可以放大局部图像了。结果希望对你有帮助,欢迎交流!
提问者评价
非常有用 太感谢了
其他类似问题
matlab的相关知识
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁magnify 画图时,将图形局部放大,很实用的代码,以前上传过一个m文件, 错误了,现修正。 matlab 182万源代码下载-
&文件名称: magnify
& & & & &&]
&&所属分类:
&&开发工具: matlab
&&文件大小: 1 KB
&&上传时间:
&&下载次数: 4
&&提 供 者:
&详细说明:画图时,将图形局部放大,很实用的代码,以前上传过一个m文件,上传错误了,现修正。-When drawing the graphic enlarged, very practical code previously uploaded an m file upload error, now corrected.
文件列表(点击判断是否您需要的文件,如果是垃圾请在下面评价投诉):
&&magnify.m
&近期下载过的用户:
&输入关键字,在本站182万海量源码库中尽情搜索:
&[] - 实现matlab中Figure窗口的局部放大。右键单击鼠标显示该位置的局部放大图; + / - 增大或缩小放大倍数; & /, & 扩大或缩小放大区域。

我要回帖

更多关于 如何在matlab中画图 的文章

 

随机推荐