zoukankan      html  css  js  c++  java
  • MATLAB绘图,绘双坐标轴,绘一图二轴等

    clc;
    clear all;
    close all;
    
    % %% 画极坐标系
    % x = 0:.01 * pi:0.5 * pi; % y = cos(x) + sqrt(-1) * sin(x); % plot(y*2,'r','linewidth',5); % hold on % warning('off') % % x = pi * 0.5:0.01:pi; % y = cos(x) + sqrt(-1) * sin(x); % plot(y*2,'y','linewidth',5); % hold on % warning('off') % % x = pi :0.01:1.5 * pi; % y = cos(x) + sqrt(-1) * sin(x); % plot(y*2,'b','linewidth',5); % hold on % warning('off') % % x = 1.5 * pi :0.01:2 * pi; % y = cos(x) + sqrt(-1) * sin(x); % plot(y*2,'g','linewidth',5); % hold on % warning('off') % % title('极坐标系'); % text([1.5,-3,1.5,-3],[2,2,-2,-2],{'第一象限','第二象限','第三象限','第四象限'}); % legend({'[0 0.5pi]','[0.5pi pi]','[pi 1.5pi]','[1.5pi 2pi]'}); % xlim([-4,4]); % ylim([-4,4]); % % plot([-3,3],[0,0],'k','linewidth',4) % plot([0,0],[-3,3],'k','linewidth',4) % % axis off % %% 画双轴坐标(1
    % figure % ang1 = 0:.01*pi:2*pi; % amp1 = sin(0:.01*pi:2*pi); % z = amp1 .*(cos(ang1) + sqrt(-1) *sin(ang1)); % [Ax,H1,H2] = plotyy(0:200,abs(z),0:200,angle(z) * 180/pi); % set(get(Ax(1),'ylabel'),'string','sfsdf'); % set(get(Ax(2),'ylabel'),'string','dsfsdffd'); % set(H1,'linewidth',3) % set(H2,'linestyle',':','linewidth',3) %% 一图多轴
    x1
    = (0:.1:40); y1 = 4 .* cos(x1) ./ (x1 + 2); mag = magic(20); x2 = (1:.2:20); y2 = x2.^2./x2.^3; %显示第一个坐标轴对象 h11 = line(x1,y1,'color','r','linewidth',2); ax1 = gca; set(ax1,'linewidth',2); %添加第二个坐标轴对象 A = get(ax1,'position');%获取ax1的位置,为[left,bottom,width,height] A(1:2) = A(1:2) + 0.1; A(3:end) = A(3:end) - 0.2; ax2 = axes('position',A,... 'xAxisLocation','bottom',... 'yAxisLocation','left',... 'Color','none',... 'xColor','k','yColor','k'); %注意这里如果用plot函数,将会产生图像覆盖,应为line是产生几何图像 h12 = line(x2,y2,'color','k','parent',ax2,'linewidth',2); h12 = line(x2,y2+0.1,'color','k','parent',ax2,'linewidth',2); set(ax2,'linewidth',2); box off xlim([0,20]); ylim([0,2]); % xlimitsl = get(ax1,'xlim')
  • 相关阅读:
    【iOS】找工作的面试题集锦
    APP项目优化--启动速度优化篇
    【Swift】Timer定时器到底准不准确?
    leetcode刷题 495~
    leetcode刷题 464~
    leetcode刷题 441~
    leetcode刷题 420~
    leetcode刷题 396~
    leetcode刷题 373~
    leetcode刷题 307~
  • 原文地址:https://www.cnblogs.com/Kermit-Li/p/4657761.html
Copyright © 2011-2022 走看看