%   Gaia H-R diagram

    infile='gaiaedr3_100pc_plotting.txt';
    A=readmatrix(infile,'Delimiter',' ','CommentStyle','#');
    
    color=A(:,1);
    G=A(:,2);
    clear A
    
    figure(1)       %plot HR diagram
    plot(color,G,'.')
    ax=gca;
    ax.YDir='reverse';  %traditional to reverse direction of y axis
        xlabel('bp$-$rp','Interpreter','LaTeX')
        ylabel('G')
        title('Gaia stars within 100 pc')
        set(gca,'FontSize',16,'LineWidth',2)
        exportgraphics(gca,'Gaia_HR.png')
    
    figure(2)   %HR diagram as a contour (log) diagram
    H=hist3([color G],[100 100]);
    colorbar
    view(2)
    colormap(flipud(hot))
        xlabel('bp$-$rp','Interpreter','LaTeX')
        ylabel('G')
        title('Gaia stars within 100 pc')
        set(gca,'FontSize',16,'LineWidth',2)
        set(gca,'zscale','log')
        exportgraphics(gca,'Gaia_HR_log.png')
    

 
    
    
    