

一番下に載せたカンマ区切りのcsvファイルを、contourで等高線にしたいです。  
空白欄のNANの部分を0に置き換えた上で下記のコードで実行すると、等高線は出てくるのですが、0という値は考えないので本当は出てきてほしくないです。

・NANの空欄ところの処理はどうすれば良いのでしょうか？  
・y軸の値は0.01〜1.00なのに、実行すると0~100になってしまうのはなぜでしょうか？  
・colorbarを0~1で作成したいのに0~1.05で作成されてしまうのはなぜでしょうか？

お願いいたします。

[code]

    import pandas as pd
    from mpl_toolkits.mplot3d import Axes3D
    import matplotlib.pyplot as plt
    import numpy as np
    
    data = pd.read_csv('xyz.csv')
    
    Xgrid = data.columns.values.astype(np.float32)
    Ygrid = data.index.values.astype(np.float32)
    X, Y = np.meshgrid(Xgrid, Ygrid)
    Z = data.as_matrix()
    
    fig = plt.figure(figsize=(12, 4))
    ax = fig.add_subplot(121)
    ax.set_title("contour")
    contour = ax.contourf(X, Y, Z)
    print(type(contour))
    fig.colorbar(contour)
    contour.set_clim(vmin=0, vmax=1)
    
    ax.set_xlabel('X')
    ax.set_ylabel('Y')
    
    plt.show()
    
[/code]

[![](https://i.stack.imgur.com/fz3aA.png)](https://i.stack.imgur.com/fz3aA.png)

↓csv

[code]

    NAN,2,4,6,8,10,12
    0.01,0.010498504,0.011303108,0.011666359,0.012759248,0.013354973,0.01397708
    0.02,0.020531799,0.021815456,0.024085167,0.025540175,0.026609816,0.028023467
    0.03,0.031287853,0.032856921,0.036288045,0.038293067,0.040738222,0.042261579
    0.04,0.040915843,0.044471039,0.047144054,0.051531803,0.05450982,0.056534606
    0.05,0.051976115,0.055683682,0.058482424,0.06367321,0.067322789,0.071311501
    0.06,0.061870274,0.067445033,0.071195003,0.075676264,0.08072713,0.086071679
    0.07,0.072325854,0.077800658,0.083336758,0.088376392,0.093933563,0.09905182
    0.08,0.082514305,0.088789185,0.094961063,0.101997795,0.107325018,0.114141031
    0.09,0.092328013,0.100336957,0.106766471,0.11260026,0.120538155,0.127562176
    0.1,0.102940751,0.11001562,0.117793483,0.125119284,0.133941713,0.141182709
    0.11,0.114300193,0.121964344,0.130636839,0.138746522,0.146051339,0.155901877
    0.12,0.12402152,0.131957239,0.141518621,0.150602168,0.159316979,0.168641447
    0.13,0.134382281,0.143599567,0.152837923,0.162689941,0.172675174,0.182777689
    0.14,0.143943924,0.155212901,0.165663865,0.175482449,0.186231189,0.196459954
    0.15,0.154608556,0.164867969,0.175699947,0.187199308,0.198227365,0.210015533
    0.16,0.163087497,0.175821756,0.188129377,0.200734339,0.212353855,0.223795837
    0.17,0.173300677,0.186919555,0.198873068,0.21091243,0.224448332,0.236318693
    0.18,0.183370367,0.196336055,0.210299291,0.222044012,0.236659655,0.250034392
    0.19,0.192693267,0.205354039,0.219712742,0.233238718,0.247452278,0.261774324
    0.2,0.201063546,0.213856315,0.228936993,0.243842837,0.256504132,0.27029175
    0.21,0.207033598,0.220144082,0.235889182,0.250454848,0.264349735,0.278523329
    0.22,0.212145499,0.224960035,0.240851238,0.256447538,0.270797621,0.284433216
    0.23,0.215390992,0.22805664,0.244042399,0.260095636,0.274851199,0.289883206
    0.24,0.21652219,0.230321215,0.246199705,0.262167266,0.278122464,0.293163265
    0.25,0.218042413,0.231010539,0.247740563,0.264053875,0.279665063,0.295342337
    0.26,0.218706313,0.232268858,0.24911033,0.265084335,0.281139575,0.296936656
    0.27,0.21882255,0.232237426,0.249708493,0.265538486,0.28179738,0.298049396
    0.28,0.219465989,0.232414699,0.249582244,0.26639507,0.282879908,0.299286035
    0.29,0.219508566,0.232876077,0.250183802,0.266904423,0.283018695,0.299746804
    0.3,0.219929544,0.23339849,0.249936701,0.266965806,0.283753208,0.299838313
    0.31,0.219816528,0.233078947,0.250194686,0.26719236,0.284023731,0.299815066
    0.32,0.219617402,0.232591013,0.25038528,0.267403763,0.283744415,0.300448144
    0.33,0.220095149,0.232191193,0.250672346,0.267757001,0.283978804,0.30072154
    0.34,0.220351828,0.232884958,0.250482536,0.26713411,0.284114022,0.300865639
    0.35,0.219390413,0.233235062,0.250437173,0.267477597,0.284237137,0.300712659
    0.36,0.219292635,0.233026183,0.250305351,0.26751286,0.284197956,0.300855016
    0.37,0.220072598,0.232782739,0.250625503,0.267692309,0.284273706,0.301246217
    0.38,0.220187442,0.233164623,0.250407047,0.268110153,0.284477796,0.300542352
    0.39,0.219831069,0.233023484,0.250275573,0.267880291,0.284521853,0.300700208
    0.4,0.220497755,0.233063362,0.250792588,0.267558223,0.284131697,0.30124465
    0.41,0.219847351,0.2323312,0.250586844,0.267560051,0.284299914,0.300857803
    0.42,0.219608695,0.233387258,0.250122332,0.267461402,0.284188553,0.300916226
    0.43,0.220053443,0.233357655,0.250695767,0.267699884,0.284379408,0.301623399
    0.44,0.219707866,0.232953742,0.250175096,0.268018121,0.284718193,0.301034988
    0.45,0.219991276,0.232894535,0.250285847,0.267787127,0.284882056,0.301085052
    0.46,0.220442205,0.232965758,0.250698031,0.267412208,0.285239997,0.300878612
    0.47,0.220056839,0.232871723,0.24984049,0.268041107,0.284371049,0.300906126
    0.48,0.220258925,0.232792055,0.250162993,0.267353263,0.284232349,0.302089392
    0.49,0.220103333,0.232835503,0.250367431,0.267592702,0.284598647,0.300939909
    0.5,0.219739995,0.233169325,0.250510659,0.267820736,0.284283806,0.300991366
    0.51,0.220196497,0.232750523,0.250268869,0.267672109,0.2844744,0.301215656
    0.52,0.219941385,0.232702461,0.250450059,0.267648339,0.284707483,0.301218529
    0.53,0.219920924,0.232836286,0.250763681,0.267728965,0.284330301,0.301033769
    0.54,0.2195925,0.233089569,0.250185457,0.267835189,0.284663514,0.301161934
    0.55,0.22022671,0.23290211,0.250306831,0.267736801,0.284719934,0.300941215
    0.56,0.219946958,0.233725259,0.250644658,0.267221789,0.284268308,0.301034727
    0.57,0.219668773,0.232691404,0.250536257,0.267436849,0.284598734,0.300946526
    0.58,0.219732159,0.233143204,0.250283757,0.268280459,0.284561382,0.301401983
    0.59,0.220201199,0.233082169,0.250300562,0.26742048,0.284205096,0.301129022
    0.6,0.219867377,0.232808076,0.250362381,0.267516169,0.284812053,0.301209474
    0.61,0.220375511,0.232911775,0.25045241,0.267654869,0.284370962,0.301204511
    0.62,0.220005642,0.232778124,0.250273222,0.267715469,0.285006043,0.301253357
    0.63,0.220552348,0.23297281,0.25038972,0.267732012,0.284603784,0.301036642
    0.64,0.219890276,0.232946167,0.25054627,0.268034925,0.284595687,0.300856584
    0.65,0.219795719,0.23260921,0.250004092,0.267503021,0.284633736,0.301082353
    0.66,0.219688624,0.233257351,0.250739998,0.267005161,0.284193255,0.301476253
    0.67,0.2201581,0.232875815,0.250249365,0.267744463,0.28441737,0.301464847
    0.68,0.219671211,0.233063362,0.250348101,0.267645727,0.284723417,0.300871821
    0.69,0.219572736,0.232403031,0.250347753,0.267153701,0.284043409,0.301305075
    0.7,0.219641346,0.233100801,0.250127382,0.267511902,0.284367131,0.30090482
    0.71,0.219866506,0.232374386,0.250328337,0.267767711,0.284516454,0.301294801
    0.72,0.219925626,0.23306014,0.250311184,0.267803148,0.284384545,0.300918141
    0.73,0.219401297,0.232465808,0.250144273,0.267540983,0.284384371,0.301489749
    0.74,0.219384493,0.232605815,0.250414448,0.267569542,0.284585065,0.301088622
    0.75,0.219415315,0.233137632,0.25030152,0.267807849,0.284549018,0.301398849
    0.76,0.219612178,0.233105851,0.250490111,0.267305288,0.284442359,0.301057016
    0.77,0.219539736,0.23256794,0.250081148,0.267713293,0.284764078,0.301101595
    0.78,0.219816441,0.232915432,0.250096821,0.267713728,0.284453329,0.301333808
    0.79,0.219972469,0.232768982,0.24998781,0.267585127,0.284702869,0.30101592
    0.8,0.219887838,0.232618614,0.250205831,0.267592441,0.284430953,0.301223318
    0.81,0.219642913,0.232876512,0.250270871,0.268097005,0.284503829,0.301123363
    0.82,0.22020355,0.232187188,0.250665293,0.267765012,0.284325599,0.301280696
    0.83,0.219960976,0.232796147,0.250197298,0.26766793,0.284211452,0.300970383
    0.84,0.220294798,0.233341024,0.249983979,0.267661748,0.28498741,0.301062327
    0.85,0.220203201,0.232638117,0.250231516,0.267706762,0.284585239,0.301012785
    0.86,0.219732681,0.233002152,0.249933044,0.268137057,0.284056469,0.301411387
    0.87,0.220309774,0.232700197,0.250412271,0.267040686,0.284316805,0.301126932
    0.88,0.21992223,0.23298587,0.25059233,0.267595227,0.284709834,0.301331022
    0.89,0.219937293,0.232421925,0.250457025,0.26749771,0.284546928,0.301592577
    0.9,0.219867551,0.232840814,0.250393203,0.267710245,0.284432259,0.30119206
    0.91,0.220106381,0.232745299,0.250619234,0.26768308,0.284381149,0.301313869
    0.92,0.21973599,0.232533112,0.250139484,0.267840065,0.284253332,0.301413999
    0.93,0.220214085,0.2332954,0.250247189,0.26817676,0.284530472,0.301107777
    0.94,0.220175949,0.233417384,0.250984575,0.267739936,0.283874147,0.301251354
    0.95,0.219914046,0.233293224,0.250134434,0.267305897,0.284527686,0.301546256
    0.96,0.220257271,0.233454736,0.249868091,0.267342553,0.284554503,0.300924933
    0.97,0.220140338,0.233138938,0.250467734,0.267070289,0.284317589,0.301023233
    0.98,0.220079128,0.233214078,0.250423242,0.267028931,0.284501478,0.301416872
    0.99,0.220183437,0.233474936,0.250254415,0.267778855,0.284733952,0.301398936
    1,0.219799463,0.232916651,0.25021654,0.267589045,0.284452023,0.300886797
    
[/code]


CC BY-SA 4.0
2019-11-10T14:01:58.607
60391
2019-11-11T02:08:25.857
2019-11-11T02:08:25.857
36557
36557
question
python pandas matplotlib csv
pythonのmatplotlib