How to plot a 2nd Yaxis on a 2D plot
Afficher commentaires plus anciens
I am wanting to plot a second Y axis on my 2D plot.
I need to include 'Elevation' from the textread line
So my plot should be, left yaxis = Bougeur Anomaly, right Yaxis = Elevation, Xaxis = Profile
My code so far
%% Program for reading data from txt file
clear all;
close all;
main_path = 'C:\Users\user\Documents\';
print_check = 1;
data_path= strcat(main_path, 'Data\gobs_elevation_2021.txt');
scriptname = mfilename( 'fullpath' );
%% Read data file
[Profile Elevation gobs]=textread(data_path,'%f %f %f', 'headerlines', 1);
FreeAir = 3.086*Elevation;
Bouguer = 0.4192*2.65*Elevation;
gLat = -8.108*sind(2*52);
gBAnom = gobs+gLat+(FreeAir-Bouguer);
%%Simple Plot
fig1=figure('Position',[10 10 550 550])
hold on
plot(Profile, gobs,'.k','Markersize',8)
plot(Profile, gBAnom,'.r','Markersize',8)
% hold on
% plot(depth,fit,'Linewidth', 2,'LineStyle','--','Color',[0.17 0.3 0.34])
grid on
%xlim([0 100])
%ylim([-10 10])
%set(gca,'YDir','reverse')
set(gca,'YDir','reverse')
set(gca,'XDir','reverse')
xlabel('Profile [m]','FontSize',16)
ylabel('Bougeur Anomaly','FontSize',16)
thetitle = 'Effect of a Sphere';
title(thetitle,'FontSize',16);
Réponses (4)
Star Strider
le 28 Mar 2021
0 votes
3 commentaires
Star Strider
le 28 Mar 2021
nicholas moran
le 29 Mar 2021
Star Strider
le 29 Mar 2021
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.
nicholas moran
le 28 Mar 2021
0 votes
nicholas moran
le 28 Mar 2021
Modifié(e) : nicholas moran
le 28 Mar 2021
0 votes
Catégories
En savoir plus sur Integration with Online Platforms dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
