How do I modify the Matlab command spy to have more visible (red) nodes of graphs? Say something like this THIS on page 7.
MATLAB: Spy, making nodes more visible
MATLABmatlab command parameterplotting graphspy
Related Solutions
There are so many properties you can set. for example:
plot(1:10);ax = gca;get(ax) % Display what properties we can alter
ALim: [0 1] ALimMode: 'auto' ActivePositionProperty: 'outerposition' AmbientLightColor: [1 1 1] BeingDeleted: 'off' Box: 'on' BoxStyle: 'back' BusyAction: 'queue' ButtonDownFcn: '' CLim: [0 1] CLimMode: 'auto' CameraPosition: [5.5000 5.5000 17.3205] CameraPositionMode: 'auto' CameraTarget: [5.5000 5.5000 0] CameraTargetMode: 'auto' CameraUpVector: [0 1 0] CameraUpVectorMode: 'auto' CameraViewAngle: 6.6086 CameraViewAngleMode: 'auto' Children: [1×1 Line] Clipping: 'on' ClippingStyle: '3dbox' Color: [1 1 1] ColorOrder: [7×3 double] ColorOrderIndex: 2 CreateFcn: '' CurrentPoint: [2×3 double] DataAspectRatio: [4.5000 4.5000 1] DataAspectRatioMode: 'auto' DeleteFcn: '' FontAngle: 'normal' FontName: 'Helvetica' FontSize: 10 FontSmoothing: 'on' FontUnits: 'points' FontWeight: 'normal' GridAlpha: 0.1500 GridAlphaMode: 'auto' GridColor: [0.1500 0.1500 0.1500] GridColorMode: 'auto' GridLineStyle: '-' HandleVisibility: 'on' HitTest: 'on' Interruptible: 'on' LabelFontSizeMultiplier: 1.1000 Layer: 'bottom' Legend: [0×0 GraphicsPlaceholder] LineStyleOrder: '-' LineStyleOrderIndex: 1 LineWidth: 0.5000 MinorGridAlpha: 0.2500 MinorGridAlphaMode: 'auto' MinorGridColor: [0.1000 0.1000 0.1000] MinorGridColorMode: 'auto' MinorGridLineStyle: ':' NextPlot: 'replace' OuterPosition: [0 0 1 1] Parent: [1×1 Figure] PickableParts: 'visible' PlotBoxAspectRatio: [1 0.7903 0.7903] PlotBoxAspectRatioMode: 'auto' Position: [0.1300 0.1100 0.7750 0.8150] Projection: 'orthographic' Selected: 'off' SelectionHighlight: 'on' SortMethod: 'childorder' Tag: '' TickDir: 'in' TickDirMode: 'auto' TickLabelInterpreter: 'tex' TickLength: [0.0100 0.0250] TightInset: [0.0363 0.0532 0.0134 0.0202] Title: [1×1 Text] TitleFontSizeMultiplier: 1.1000 TitleFontWeight: 'bold' Type: 'axes' UIContextMenu: [0×0 GraphicsPlaceholder] Units: 'normalized' UserData: [] View: [0 90] Visible: 'on' XAxis: [1×1 NumericRuler] XAxisLocation: 'bottom' XColor: [0.1500 0.1500 0.1500] XColorMode: 'auto' XDir: 'normal' XGrid: 'off' XLabel: [1×1 Text] XLim: [1 10] XLimMode: 'auto' XMinorGrid: 'off' XMinorTick: 'off' XScale: 'linear' XTick: [1 2 3 4 5 6 7 8 9 10] XTickLabel: {10×1 cell} XTickLabelMode: 'auto' XTickLabelRotation: 0 XTickMode: 'auto' YAxis: [1×1 NumericRuler] YAxisLocation: 'left' YColor: [0.1500 0.1500 0.1500] YColorMode: 'auto' YDir: 'normal' YGrid: 'off' YLabel: [1×1 Text] YLim: [1 10] YLimMode: 'auto' YMinorGrid: 'off' YMinorTick: 'off' YScale: 'linear' YTick: [1 2 3 4 5 6 7 8 9 10] YTickLabel: {10×1 cell} YTickLabelMode: 'auto' YTickLabelRotation: 0 YTickMode: 'auto' ZAxis: [1×1 NumericRuler] ZColor: [0.1500 0.1500 0.1500] ZColorMode: 'auto' ZDir: 'normal' ZGrid: 'off' ZLabel: [1×1 Text] ZLim: [-1 1] ZLimMode: 'auto' ZMinorGrid: 'off' ZMinorTick: 'off' ZScale: 'linear' ZTick: [-1 0 1] ZTickLabel: '' ZTickLabelMode: 'auto' ZTickLabelRotation: 0 ZTickMode: 'auto'
The colors are in the range of 0-1 and in order r, g, b. So for example, red would be [1,0,0]. So to make a font size of 20 with the x labels being red and the y labels being blue, you'd add these lines:
ax.FontSize = 20;ax.XColor = [1, 0, 0]; % X labels are red.
ax.YColor = [0, 0, 1]; % Y labels are blue.
R2014b以後のバージョンを仮定しますが、legendオブジェクトのプロパティを編集することで、凡例で表示される線の長さを変更することが可能です。
例えば、下記は凡例の線を長く変更しています。
h1 = plot(1:10);[hh,icons,plots,txt] = legend({'Line 1'});icons(2).XData = [0.0 0.6];
下記に詳しく解説を加えます。まず、
h1 = plot(1:10);[hh,icons,plots,txt] = legend({'Line 1'});
との実行で凡例の線に関するオブジェクトがiconsとして出力されます。参考:http://jp.mathworks.com/help/matlab/ref/legend.html#outputarg_icons
icons = 3x1 graphics 配列: Text (Line 1) Line (Line 1) Line (Line 1)
3つのオブジェクトがありますが、1つ目 icons(1) は Line 1という文字列、2つ目 icons(2) は凡例の線の両端で定義される Lineオブジェクト、3つ目 icons(3) は凡例の線の中心をデータに持つ"点" です。実際にプロパティを見てみるとわかりやすいと思います。
>> icons(2)ans = Line (Line 1) のプロパティ: Color: [0 0.4470 0.7410] LineStyle: '-' LineWidth: 0.5000 Marker: 'none' MarkerSize: 6 MarkerFaceColor: 'none' XData: [0.0571 0.4857] YData: [0.5000 0.5000] ZData: [1x0 double] すべてのプロパティ を表示>> icons(3)ans = Line (Line 1) のプロパティ: Color: [0 0.4470 0.7410] LineStyle: 'none' LineWidth: 0.5000 Marker: 'none' MarkerSize: 6 MarkerFaceColor: 'none' XData: 0.2714 YData: 0.5000 ZData: [1x0 double] すべてのプロパティ を表示
ここで例えば icons(3) のプロパティの内、Marker = 'o' などとすると、凡例の線の中心に丸のマーカーが登場します。
icons(3).Marker = 'o';
凡例の示すものが線ではなく点で表される場合に活用されます。
ここまでで、凡例の線の長さに関しては icons(2)のプロパティを変更することで実現できそうなことがわかります。具体的には線の位置(特にx座標)を定義する XData を変更します。
現時点で XData: [0.0571 0.4857] の値が入っていることが上の表示で確認できますので、短くする場合には例えば
icons(2).XData = [0.1 0.3];
長くする場合には
icons(2).XData = [0.0 0.6];
などと、始点・終点位置を指定して長さを変更することができます。
Best Answer