fill in between horizontal lines
Mostra commenti meno recenti
I have my data graphed (Wetbulb Temperature vs. Time) and i would like to shade in certain regions of the grpah to represent as the temperature drops it moves into certain colored regions of the graph. Ive created horizontal lines at each point i would like to shade a different color but i cant seem to figure out how to fill in each region. Here is my code for my whole project. I will also attach the figure i get when i run the program

%% Clear windows
clear all
clc
%% load data
array1 = load ('prototype0.txt'); %load data from arduino sensors from a txt file
%% Define Variables from sensor data
Humidity= array1(:,1); %defines humidity from column 1 of array1
Pressure=array1(:,2); %defines Pressure from column 2 of array1
Altitude=array1(:,3); %defines Altitude from column 3 of array1
Temperature=array1(:,4); %defines Temperature from column 4 of array1
TimeMili=array1(:,5); %defines Time from column 7 of array1
Dewpoint=Temperature-((100-Humidity)/5);
Wetbulb=Temperature-((Temperature-Dewpoint)/3);
Time=TimeMili/1000;
green=20+Time*0;
yellow=28+Time*0;
red=100+Time*0;
base=0+Time*0;
greenarea=[base,green];
basearea=[base,base]
figure(5)
plot(Time,Wetbulb);
title('Wetbulb Temperature vs. Time');
xlabel('Time');
ylabel('Wetbulb Temperature');
axis([0 200 0 100]);
hold on
plot(Time,green)
plot(Time,yellow)
plot(Time,red)
fill(basearea,greenarea,'g')
Risposta accettata
Più risposte (1)
yregion(0,20,'FaceColor','g','EdgeColor','k')
yregion(20,28,'FaceColor','y','EdgeColor','k')
yregion(28,100,'FaceColor','r','EdgeColor','k')
Categorie
Scopri di più su Creating, Deleting, and Querying Graphics Objects in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
