matlab 绘图篇1

matlab 绘图、直方图、plot图
摘要由CSDN通过智能技术生成

一、3D直方图

原代码来自作者xiaoyeyimier,如代码中的注释中所示。本文只是用于整理绘图代码,避免以前下载的代码丢失。若有侵权,请联系我删除。

clear all;
N = 6; % %这里修改每行数据个数
Data1 = [0.4997 0.4996 0.2027 0.2988 0.1050 0.028];%修改数据
Data2 = [0.5000 0.4997 0.2177 0.2119 0.002 0.002];
Data3 = [0.4995 0.5001 0.4835 0.4120 0.002 0.002];

X = repmat(1:N,3,1);% 3行N列
Y = [1,1.5,2];%要改变每行的位置,修改这里
Z = [Data1;Data2;Data3];

figure('color','w','position',[0,0,800,600])
ax = newplot();hold on;
FancyBar3(X,Y,Z);%绘图

ax.YTick = Y;% 这里我是三种方法,所以3个ticks
ax.XTick = 1:N; 
ax.ZTick = 0:3;
ax.FontSize = 14;

% 这里对应Y轴3个ticks
ax.YTickLabel={'Method1\newline \it{s}\rm{=0.25}','Method2\newline \it{s}\rm{=0.5}','Method3\newline \it{s}\rm{=0.25}'};%\newline可以实现换行
ax.XTickLabel={'方法A','方法B','方法C','方法D','方法E','方法F'};
xlabel('对比方法','fontsize',10,'FontName','song','FontSize',10);
ylabel('使用Mehod','fontsize',10,'FontName','song','FontSize',10);
zlabel('错误率','fontsize',10,'FontName','song');
yyy = get(ax,'YLim');
ax.XGrid = 'off';
ax.YGrid = 'off';
ax.ZGrid = 'on';
grid on

function [ax] = FancyBar3(varargin)
% 3D histogram
% author : xiaoyeyimier
% date   : 2022-3-30
% version : 1.01
% contact : xiaoyeyimier@163.com
%=========================================================================%
%% Input
% X          : The abscissa of each set of data.
%              Each row of data must be uniform and increasing
% Y          : The position of each histogram on the plane
% Z          : yData of the data of each group
% B3settings : Drawing parameters,
% |            including the length, width and height of each cube
% |___dWidth         : The interval between adjacent pieces of data in the 
% |                    same set;
% |___LineWidth      : The border thickness of the histogram;
% |___TempYWidth     : The interval between different datasets;
% |___TempFaceAlpha  : The opacity of the histogram;
% |___ViewAngle      : angle of view ;
% |___colorarr       : Colors used for different groups of data;
% ax          : You can specify a coordinate handle that is currently in use
%=========================================================================%
%% Output
% ax         : Handle to the coordinate axes used for drawing
%=========================================================================%
% read & check parameters
[X,Y,Z,B3,ax] = inputParamCheck(varargin,nargin);
B3 = StructCompletion(B3,X);
TempFaceAlpha  = B3.TempFaceAlpha;
colorarr = B3.colorarr;
LineWidth = B3.LineWidth;
% draw plane by plane
for looptimeI = 1:length(Y)
    if looptimeI==length(Y)
        TempYWidth = B3.TempYWidth*(Y(looptimeI)-Y(looptimeI-1));
    else
        TempYWidth = B3.TempYWidth*(Y(looptimeI+1)-Y(looptimeI
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值