Error in longitude contour near the ploe MATLAB











up vote
1
down vote

favorite












I want to plot lat/lon contours at the south pole, my data consists of grid cells, each with a lat and lon value. My problem is where the longitudes "meets" each other, as you can see in the picture, the vertical longitude in the lower part of the picture have a lot of lines on top of each other.lat/lon contours
Does anyone know how to remove them? Here is my code:



coldiv = -57.5:2.5:-7.5; 
min_pr = coldiv(1); max_pr = coldiv(end);
cmap = [0 0 0.4; 0 0 0.7; 0 0 1; 0 0.2 1; 0 0.4 1; 0 0.6 1; 0 0.8 1; 0 1 1;
0 1 0; 0.6 0.8 0; 0.6 0.6 0; 0.6 0.4 0; 0.6 0.2 0; 1 0 0];


x = linspace(1,length(coldiv)-2,length(cmap));
xi = 1:length(coldiv)-2;
cmap = interp1(x,cmap,xi);
cmap = [0. 0. 0.; cmap];
fig=figure();
set(fig, 'Position', [10 10 1500 700])


pcolor(mean(tas_ann_DMI_hist_tot,3))
shading flat
hold on;
contour(flip_lat_DMI, 'k','ShowText','on');
contour(flip_lon_DMI, 'k','ShowText','on');
caxis([min_pr max_pr]);colormap(cmap);
axesHandles = findobj(get(fig,'Children'), 'flat','Type','axes');
axis(axesHandles,'square')
set(gca,'YTick',);
set(gca,'XTick',);









share|improve this question
























  • Could you show what your desired output is?
    – Mad Physicist
    Nov 20 at 13:10










  • Ideally I want all the lines that are on top of each other removed. So there are line vertical lines between longitude -150 and 150
    – Nicolaj Hansen
    Nov 20 at 13:17






  • 2




    What about manually drawing meridians with line or plot ? Drawing contour lines on longitudes is bound to fail where they suddenly drop from 180° to -180°. You may have to label meridians manually, though.
    – Brice
    Nov 20 at 13:52






  • 1




    Can you put a Minimal, Complete, and Verifiable example? Give us some random data for the variables not defined in your code
    – Ander Biguri
    Nov 20 at 14:43






  • 1




    Can't you use the polaraxes function ?
    – obchardon
    Nov 20 at 15:59















up vote
1
down vote

favorite












I want to plot lat/lon contours at the south pole, my data consists of grid cells, each with a lat and lon value. My problem is where the longitudes "meets" each other, as you can see in the picture, the vertical longitude in the lower part of the picture have a lot of lines on top of each other.lat/lon contours
Does anyone know how to remove them? Here is my code:



coldiv = -57.5:2.5:-7.5; 
min_pr = coldiv(1); max_pr = coldiv(end);
cmap = [0 0 0.4; 0 0 0.7; 0 0 1; 0 0.2 1; 0 0.4 1; 0 0.6 1; 0 0.8 1; 0 1 1;
0 1 0; 0.6 0.8 0; 0.6 0.6 0; 0.6 0.4 0; 0.6 0.2 0; 1 0 0];


x = linspace(1,length(coldiv)-2,length(cmap));
xi = 1:length(coldiv)-2;
cmap = interp1(x,cmap,xi);
cmap = [0. 0. 0.; cmap];
fig=figure();
set(fig, 'Position', [10 10 1500 700])


pcolor(mean(tas_ann_DMI_hist_tot,3))
shading flat
hold on;
contour(flip_lat_DMI, 'k','ShowText','on');
contour(flip_lon_DMI, 'k','ShowText','on');
caxis([min_pr max_pr]);colormap(cmap);
axesHandles = findobj(get(fig,'Children'), 'flat','Type','axes');
axis(axesHandles,'square')
set(gca,'YTick',);
set(gca,'XTick',);









share|improve this question
























  • Could you show what your desired output is?
    – Mad Physicist
    Nov 20 at 13:10










  • Ideally I want all the lines that are on top of each other removed. So there are line vertical lines between longitude -150 and 150
    – Nicolaj Hansen
    Nov 20 at 13:17






  • 2




    What about manually drawing meridians with line or plot ? Drawing contour lines on longitudes is bound to fail where they suddenly drop from 180° to -180°. You may have to label meridians manually, though.
    – Brice
    Nov 20 at 13:52






  • 1




    Can you put a Minimal, Complete, and Verifiable example? Give us some random data for the variables not defined in your code
    – Ander Biguri
    Nov 20 at 14:43






  • 1




    Can't you use the polaraxes function ?
    – obchardon
    Nov 20 at 15:59













up vote
1
down vote

favorite









up vote
1
down vote

favorite











I want to plot lat/lon contours at the south pole, my data consists of grid cells, each with a lat and lon value. My problem is where the longitudes "meets" each other, as you can see in the picture, the vertical longitude in the lower part of the picture have a lot of lines on top of each other.lat/lon contours
Does anyone know how to remove them? Here is my code:



coldiv = -57.5:2.5:-7.5; 
min_pr = coldiv(1); max_pr = coldiv(end);
cmap = [0 0 0.4; 0 0 0.7; 0 0 1; 0 0.2 1; 0 0.4 1; 0 0.6 1; 0 0.8 1; 0 1 1;
0 1 0; 0.6 0.8 0; 0.6 0.6 0; 0.6 0.4 0; 0.6 0.2 0; 1 0 0];


x = linspace(1,length(coldiv)-2,length(cmap));
xi = 1:length(coldiv)-2;
cmap = interp1(x,cmap,xi);
cmap = [0. 0. 0.; cmap];
fig=figure();
set(fig, 'Position', [10 10 1500 700])


pcolor(mean(tas_ann_DMI_hist_tot,3))
shading flat
hold on;
contour(flip_lat_DMI, 'k','ShowText','on');
contour(flip_lon_DMI, 'k','ShowText','on');
caxis([min_pr max_pr]);colormap(cmap);
axesHandles = findobj(get(fig,'Children'), 'flat','Type','axes');
axis(axesHandles,'square')
set(gca,'YTick',);
set(gca,'XTick',);









share|improve this question















I want to plot lat/lon contours at the south pole, my data consists of grid cells, each with a lat and lon value. My problem is where the longitudes "meets" each other, as you can see in the picture, the vertical longitude in the lower part of the picture have a lot of lines on top of each other.lat/lon contours
Does anyone know how to remove them? Here is my code:



coldiv = -57.5:2.5:-7.5; 
min_pr = coldiv(1); max_pr = coldiv(end);
cmap = [0 0 0.4; 0 0 0.7; 0 0 1; 0 0.2 1; 0 0.4 1; 0 0.6 1; 0 0.8 1; 0 1 1;
0 1 0; 0.6 0.8 0; 0.6 0.6 0; 0.6 0.4 0; 0.6 0.2 0; 1 0 0];


x = linspace(1,length(coldiv)-2,length(cmap));
xi = 1:length(coldiv)-2;
cmap = interp1(x,cmap,xi);
cmap = [0. 0. 0.; cmap];
fig=figure();
set(fig, 'Position', [10 10 1500 700])


pcolor(mean(tas_ann_DMI_hist_tot,3))
shading flat
hold on;
contour(flip_lat_DMI, 'k','ShowText','on');
contour(flip_lon_DMI, 'k','ShowText','on');
caxis([min_pr max_pr]);colormap(cmap);
axesHandles = findobj(get(fig,'Children'), 'flat','Type','axes');
axis(axesHandles,'square')
set(gca,'YTick',);
set(gca,'XTick',);






matlab matlab-figure latitude-longitude






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 20 at 13:06

























asked Nov 20 at 12:58









Nicolaj Hansen

184




184












  • Could you show what your desired output is?
    – Mad Physicist
    Nov 20 at 13:10










  • Ideally I want all the lines that are on top of each other removed. So there are line vertical lines between longitude -150 and 150
    – Nicolaj Hansen
    Nov 20 at 13:17






  • 2




    What about manually drawing meridians with line or plot ? Drawing contour lines on longitudes is bound to fail where they suddenly drop from 180° to -180°. You may have to label meridians manually, though.
    – Brice
    Nov 20 at 13:52






  • 1




    Can you put a Minimal, Complete, and Verifiable example? Give us some random data for the variables not defined in your code
    – Ander Biguri
    Nov 20 at 14:43






  • 1




    Can't you use the polaraxes function ?
    – obchardon
    Nov 20 at 15:59


















  • Could you show what your desired output is?
    – Mad Physicist
    Nov 20 at 13:10










  • Ideally I want all the lines that are on top of each other removed. So there are line vertical lines between longitude -150 and 150
    – Nicolaj Hansen
    Nov 20 at 13:17






  • 2




    What about manually drawing meridians with line or plot ? Drawing contour lines on longitudes is bound to fail where they suddenly drop from 180° to -180°. You may have to label meridians manually, though.
    – Brice
    Nov 20 at 13:52






  • 1




    Can you put a Minimal, Complete, and Verifiable example? Give us some random data for the variables not defined in your code
    – Ander Biguri
    Nov 20 at 14:43






  • 1




    Can't you use the polaraxes function ?
    – obchardon
    Nov 20 at 15:59
















Could you show what your desired output is?
– Mad Physicist
Nov 20 at 13:10




Could you show what your desired output is?
– Mad Physicist
Nov 20 at 13:10












Ideally I want all the lines that are on top of each other removed. So there are line vertical lines between longitude -150 and 150
– Nicolaj Hansen
Nov 20 at 13:17




Ideally I want all the lines that are on top of each other removed. So there are line vertical lines between longitude -150 and 150
– Nicolaj Hansen
Nov 20 at 13:17




2




2




What about manually drawing meridians with line or plot ? Drawing contour lines on longitudes is bound to fail where they suddenly drop from 180° to -180°. You may have to label meridians manually, though.
– Brice
Nov 20 at 13:52




What about manually drawing meridians with line or plot ? Drawing contour lines on longitudes is bound to fail where they suddenly drop from 180° to -180°. You may have to label meridians manually, though.
– Brice
Nov 20 at 13:52




1




1




Can you put a Minimal, Complete, and Verifiable example? Give us some random data for the variables not defined in your code
– Ander Biguri
Nov 20 at 14:43




Can you put a Minimal, Complete, and Verifiable example? Give us some random data for the variables not defined in your code
– Ander Biguri
Nov 20 at 14:43




1




1




Can't you use the polaraxes function ?
– obchardon
Nov 20 at 15:59




Can't you use the polaraxes function ?
– obchardon
Nov 20 at 15:59












1 Answer
1






active

oldest

votes

















up vote
0
down vote



accepted










I found a solution.



flip_lon_DMI(flip_lon_DMI<-160) = NaN;
flip_lon_DMI(flip_lon_DMI>190) = NaN;

...

contour(flip_lat_DMI,-90:5:-60,'k--','ShowText','on','Color',[.5 .5 .5]);
contour(flip_lon_DMI,-150:30:180,'k--','ShowText','on','Color',[.5 .5 .5]);





share|improve this answer





















    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














     

    draft saved


    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53393536%2ferror-in-longitude-contour-near-the-ploe-matlab%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote



    accepted










    I found a solution.



    flip_lon_DMI(flip_lon_DMI<-160) = NaN;
    flip_lon_DMI(flip_lon_DMI>190) = NaN;

    ...

    contour(flip_lat_DMI,-90:5:-60,'k--','ShowText','on','Color',[.5 .5 .5]);
    contour(flip_lon_DMI,-150:30:180,'k--','ShowText','on','Color',[.5 .5 .5]);





    share|improve this answer

























      up vote
      0
      down vote



      accepted










      I found a solution.



      flip_lon_DMI(flip_lon_DMI<-160) = NaN;
      flip_lon_DMI(flip_lon_DMI>190) = NaN;

      ...

      contour(flip_lat_DMI,-90:5:-60,'k--','ShowText','on','Color',[.5 .5 .5]);
      contour(flip_lon_DMI,-150:30:180,'k--','ShowText','on','Color',[.5 .5 .5]);





      share|improve this answer























        up vote
        0
        down vote



        accepted







        up vote
        0
        down vote



        accepted






        I found a solution.



        flip_lon_DMI(flip_lon_DMI<-160) = NaN;
        flip_lon_DMI(flip_lon_DMI>190) = NaN;

        ...

        contour(flip_lat_DMI,-90:5:-60,'k--','ShowText','on','Color',[.5 .5 .5]);
        contour(flip_lon_DMI,-150:30:180,'k--','ShowText','on','Color',[.5 .5 .5]);





        share|improve this answer












        I found a solution.



        flip_lon_DMI(flip_lon_DMI<-160) = NaN;
        flip_lon_DMI(flip_lon_DMI>190) = NaN;

        ...

        contour(flip_lat_DMI,-90:5:-60,'k--','ShowText','on','Color',[.5 .5 .5]);
        contour(flip_lon_DMI,-150:30:180,'k--','ShowText','on','Color',[.5 .5 .5]);






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 21 at 8:29









        Nicolaj Hansen

        184




        184






























             

            draft saved


            draft discarded



















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53393536%2ferror-in-longitude-contour-near-the-ploe-matlab%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Berounka

            Sphinx de Gizeh

            Different font size/position of beamer's navigation symbols template's content depending on regular/plain...