Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Discrete spikes in surface plot when not in data #10897

Open
Nacho9216 opened this issue Mar 27, 2018 · 5 comments
Open

Discrete spikes in surface plot when not in data #10897

Nacho9216 opened this issue Mar 27, 2018 · 5 comments

Comments

@Nacho9216
Copy link

Bug report

Bug summary
Surface plot has discrete spikes down the x-axis (rows) when they should look more like fins. This changes depending on the range of the y-axis (number of columns). See the two figures below. Everything appears as smooth "fins" when the data is plotted in matlab. I did try playing around with rstride, cstride, rcount, and ccount listed in https://matplotlib.org/mpl_toolkits/mplot3d/tutorial.html but I did not get any where.

I am also getting an error with 'cmap=cm.jet' but it seems to work anyways.

Any help would be appreciated as I am trying to move to python and away from matlab, but I need to be able to create various figures. Thank you.

Code for reproduction

from __future__ import division
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import cm
from mpl_toolkits.mplot3d import Axes3D
z = np.matrix([[1,0.79959,0.6393441681000001,0.511213203371079,0.408760965283481,0.3268411802310186,0.2613389393009202,0.2089640024756228,0.1670855267394832,0.1335999163256234,0.1068251570948052,0.08541632736143528,0.06829804119493005,0.05461043075905412,0.04366595433063208,0.03491486042323011,0.02791757324581056,0.02232261239161767,0.01784893764221357,0.01427183204933755,0.01141161418832981],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0.02985000000000001,0.04773552300000002,0.05725327025335503,0.06103885648250686,0.06100757406855957,0.05853725537937546,0.0546067713669273,0.04990060379117874,0.04488752675856219,0.0398795750231986,0.03507604033207931,0.03059612846086614,0.02650305488569262,0.02282169901420873,0.01955143105154052,0.01667533733813471,0.01416677254358658,0.01199393963801618,0.01012302498378143,0.008520283733454523],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0.0008910225000000007,0.002137358042325002,0.003418020234125296,0.004555024665007076,0.005463228257839512,0.006115679755760254,0.006520048501211122,0.006702898604250087,0.006699463368715409,0.006547229229433633,0.006282118823475407,0.005936413824619556,0.005537813318365475,0.005109207866805981,0.00466888173510788,0.004230949966118231,0.003805903443834536,0.00340118143285044,0.003021722957658759],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0.08972000000000002,0.1434784296,0.1720858762857961,0.1834641944258129,0.1833701690261696,0.175945144141962,0.16413130743855,0.149986002416903,0.134918221131598,0.1198658449273493,0.1054278840400052,0.09196263469041574,0.07966010332811865,0.06859506986783273,0.05876564133816468,0.05012098043475531,0.04258099941744013,0.03605012610796689,0.03042672701992865,0.02560937542933131],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,2.659702162500003e-005,8.50668500845351e-005,0.0001700465066477336,0.0002719349725009226,0.0003805138481585221,0.0004868081085585163,0.0005838703432834561,0.0006669384111228839,0.0007332562657059018,0.000781739169994376,0.0008125920698165441,0.0008269424457695043,0.0008265186377660475,0.0008133858923955125,0.0007897413454934981,0.0007577631389317754,0.0007195060460569193,0.0006768351051372378],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0.005356284000000004,0.01284849337068001,0.02054705362852406,0.02738203101805258,0.03284159727258699,0.03676373786846297,0.03919455621632574,0.04029373954930102,0.040273089007782,0.03935795018189517,0.03776426806312987,0.03568610039161584,0.03328995718082079,0.03071344253332211,0.02806647030310746,0.02543389152161659,0.02287877098699058,0.02044582902213343,0.01816475603089741],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,7.939210955062513e-007,3.174056843779217e-006,7.613832335152274e-006,1.420520312601695e-005,2.271667673506378e-005,3.269524959106137e-005,4.357132436752793e-005,5.474730682304975e-005,6.566309859396353e-005,7.583847122907944e-005,8.489555649408349e-005,9.256587002332394e-005,9.868632534926612e-005,0.0001031881677740258,0.0001060820062334142,0.0001074413410612892,0.0001073862773739953],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0.0002398276161000002,0.0007670550542295969,0.001533323877028608,0.00245206087766661,0.003431125875053528,0.004389590301494481,0.005264808763757958,0.00601384062773318,0.006611834387852613,0.007049008877577428,0.007327212110948777,0.007456610676828132,0.007452789163856258,0.007334370076957323,0.007121165177655943,0.006832814957282298,0.006487847482635856,0.006103079963106829],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0.08084,0.1373273896,0.17436307470318,0.1961849910827954,0.2063722009772929,0.2078869607543372,0.2031367731350637,0.1940446432945816,0.1821200944503789,0.1685264863572688,0.1541422025328344,0.1396146093831968,0.1254065467513326,0.1118356324100587,0.09910695873538912,0.08733990379270384,0.07658982465940564,0.06686538515288526,0.05814221874779886,0.05037355753964894],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,2.369854470086161e-008,1.136947161441716e-007,3.181820532860136e-007,6.784405012985698e-007,1.220567040974978e-006,1.951906400586365e-006,2.861328871215561e-006,3.922097060803286e-006,5.096113081877512e-006,6.338579425326463e-006,7.602397084045179e-006,8.841891904627906e-006,1.001567515969702e-005,1.108860050899681e-005,1.203288196705618e-005,1.282849612271793e-005],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,9.545139120780013e-006,3.816098894792246e-005,9.153943545860797e-005,0.0001707860401294795,0.000273117619654261,0.0003930878114988309,0.000523848471993917,0.0006582148567053968,0.0007894530259096023,0.0009117892983146407,0.001020680647055165,0.001112899143516599,0.001186484034885917,0.001240608698517332,0.00127540068331818,0.001291743667674219,0.001291081649044536],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0.004826148000000001,0.01229766773868001,0.0208189511195597,0.02928060991910722,0.03696126119503318,0.04343798044961877,0.04850906142465322,0.05213009342108937,0.05436284819343812,0.05533567179540924,0.05521373694726131,0.05417744917114953,0.05240739588738189,0.05007440441160382,0.04733348349202186,0.04432063417960759,0.04115171278949867,0.0379227031894589,0.03471090459243593],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,7.074015593207194e-010,3.959418489720777e-009,1.266364572078335e-008,3.037717344564348e-008,6.072321028850517e-008,1.068180777720889e-007,1.708213336115691e-007,2.536616274074526e-007,3.549442761527688e-007,4.730164896149874e-007,6.051508078899965e-007,7.478030078339054e-007,8.969037105508687e-007,1.048149963112924e-006,1.19727175572209e-006],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,3.561530034441044e-007,1.708658280143229e-006,4.781791259769036e-006,1.019592659572993e-005,1.834326213002931e-005,2.933417793310027e-005,4.300141144480068e-005,5.89431404179683e-005,7.658681167605532e-005,9.525918694142212e-005,0.0001142524399297376,0.000132880157735882,0.0001505203308757147,0.0001666447634283407,0.0001808358743859765,0.0001927927424003773],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0.0002160907767000002,0.0007341707639991966,0.001553614227297144,0.002622078618256053,0.003861527763351093,0.005186494865684482,0.006515979675866547,0.007780416443097592,0.008925020602157708,0.009910618818557799,0.01071284531119238,0.0113203780043117,0.01173270575428763,0.011957767773491,0.01200968809901325,0.01190673837235158,0.01166959695428209,0.01131992690205348],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,2.111593654572348e-011,1.350727336207603e-010,4.860126318412068e-010,1.295369467646369e-009,2.84835229974724e-009,5.46603363685175e-009,9.46960264399563e-009,1.514359915622493e-008,2.270375709248605e-008,3.22732393485883e-008,4.386911106625412e-008,5.739922230130822e-008,7.266841991984648e-008,8.939221828263084e-008],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0.0145059296,0.03551860589264001,0.0579555993870091,0.07877368059118972,0.09632600559966767,0.1098963343887536,0.1193658161929138,0.1249782668014643,0.1271779762221492,0.1265003892673693,0.1235008748113358,0.1187105466326296,0.112610964109559,0.1056217191803083,0.09809656122289909,0.09032494561484489,0.08253681032552157,0.07490906271866871,0.06757275393756386],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,1.275740058336783e-008,7.140482952718556e-008,2.283783505665692e-007,5.478271359885693e-007,1.09509274916275e-006,1.926375464866696e-006,3.080621115905522e-006,4.574577127838523e-006,6.401125719884707e-006,8.530460190604354e-006,1.091339306208854e-005,1.348600720861467e-005,1.617491475590431e-005,1.890251551567669e-005,2.159180340168561e-005],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,8.600412912660009e-006,3.652499550896005e-005,9.275076936963951e-005,0.0001826277757615342,0.0003073776099627471,0.0004644506152220456,0.0006483399777487217,0.0008515665796970317,0.001065647459897631,0.001281938544180452,0.001492299351849099,0.001689566417143522,0.001867846756082591,0.002022656418886003,0.002150935138533275,0.002250968889293068,0.002322249793902137],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,6.303107058898462e-013,4.535911235902159e-012,1.813434632557504e-011,5.316682058771066e-011,1.275349742211827e-010,2.651367940975403e-010,4.946683681157219e-010,8.475683152749645e-010,1.355414298421418e-009,2.047131913430142e-009,2.946359171987294e-009,4.069246116023371e-009,5.422880836518545e-009],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0.001299005995680001,0.004240921543581219,0.008649873208511112,0.01410836619388208,0.02012731887005057,0.02624324465203437,0.0320676265202263,0.03730601264023709,0.0417588884925427,0.04531243943557171,0.04792451447053887,0.04960913743777592,0.05042155918005505,0.05044493308051527,0.04977909999256015,0.04853159327885617,0.04681075197611957,0.04472071044304523],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,4.442764753157847e-010,2.841912215181986e-009,1.022564064661814e-008,2.725440001543133e-008,5.992895069793153e-008,1.150046152525418e-007,1.992391706711897e-007,3.186192969539532e-007,4.776840068463964e-007,6.790246311721069e-007,9.230002182261385e-007,1.207671945531444e-006,1.528933817301855e-006,1.880800293809831e-006],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,3.209029068036267e-007,1.635406673913687e-006,4.845068314946545e-006,1.090287821296359e-005,2.064424872912301e-005,3.465962716094516e-005,5.32206079234482e-005,7.625778721186922e-005,0.0001033811242033189,0.0001339305294032528,0.0001670442586976086,0.0002017342302069366,0.0002369597090935278,0.0002716933234668625,0.0003049757159547868,0.0003359571067269905],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,1.881477457081192e-014,1.50441055990755e-013,6.616014017780628e-013,2.116039459390885e-012,5.498882971836664e-012,1.231118513926246e-011,2.460975131375718e-011,4.49776252639248e-011,7.642277619266097e-011,1.222137752317796e-010,1.856697338213994e-010,2.699266590295504e-010],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,7.755065794209607e-005,0.0003164787701897486,0.0007745961458221703,0.001473971558105831,0.002403201873084039,0.003525123837884519,0.004786093258143778,0.006124714625210928,0.007479016929014401,0.008791746061486807,0.0100138272986191,0.01110624564388209,0.01204066833219715,0.01279914064585375,0.01337315521300129,0.01376234656405165,0.0139730094648717],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,1.515617461505849e-011,1.090685309440916e-010,4.360505332879308e-010,1.278426035009554e-009,3.066650019999869e-009,6.375362992678408e-009,1.189457848907003e-008,2.038025574444752e-008,3.259169738140557e-008,4.922443558404083e-008,7.084685960755777e-008,9.784730627259412e-008,1.303962127041726e-007],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0.0065351056,0.01762842326568,0.03137775123869781,0.04614870716908601,0.06065074811497538,0.07394368281503597,0.08540610520367213,0.09468593765256642,0.1016455674204116,0.1063088684374597,0.1088139786917312,0.109373512732732,0.1082425425292224,0.1056939028048798,0.1019999749327799,0.09741994125202219,0.09219148637173466,0.08652599094614036,0.08060637517131539],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,1.149474212170591e-008,6.8343644902853e-008,2.314004627218471e-007,5.85811646382534e-007,1.232461649128644e-006,2.27609771565927e-006,3.812724351635831e-006,5.918366865513173e-006,8.6405943609134e-006,1.199347890806129e-005,1.595606759079558e-005,2.0474007023702e-005,2.546369033919051e-005,3.081817368084622e-005,3.641410048500155e-005],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,5.61621020938736e-016,4.939732073456441e-015,2.369856221169022e-014,8.211291122166333e-014,2.297983193930543e-013,5.512333146104769e-013,1.175361722745043e-012,2.282389594017865e-012,4.106195764831675e-012,6.931354262270381e-012,1.108448310913755e-011],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,3.858145232619281e-006,1.8893782580328e-005,5.395062155651418e-005,0.0001173281360252242,0.0002152067277346758,0.0003507498218695098,0.0005238379071038367,0.0007312909262501851,0.0009674108397680132,0.001224690226365113,0.001494563724318901,0.00176811430650603,0.002036679048391149,0.002292326089672407,0.002528194993017896,0.00273870696624628],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,5.089632887919332e-013,4.069619560851418e-012,1.789714907563652e-011,5.724152571755282e-011,1.487516925326187e-010,3.330330243300385e-010,6.657246898101387e-010,1.216701267943517e-009,2.067332104524283e-009,3.306036154913143e-009,5.022599553303301e-009,7.301855230592339e-009],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0.0005852187064800001,0.002104833737922193,0.00468312937237565,0.008265233453983308,0.01267297381862411,0.0176577514562306,0.02294435016296653,0.02826375238929109,0.03337532206249216,0.0380798366742981,0.04222526443132629,0.04570719097100872,0.04846559841745936,0.05047940797961058,0.05175988727963919,0.05234373443471154,0.05228640149572934,0.05165601659484582],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,4.003043943884086e-010,2.72007706713355e-009,1.036095571837071e-008,2.914412940753108e-008,6.744646374856507e-008,1.358830336248585e-007,2.465879474420475e-007,4.122142521829927e-007,6.448043541831627e-007,9.54680921081679e-007,1.349484416491537e-006,1.833447328972515e-006,2.406955329311984e-006,3.066408281244201e-006],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,1.676438747502128e-017,1.608556389738271e-016,8.360206423860357e-016,3.119544145412102e-015,9.353836137112736e-015,2.393354827799671e-014,5.422157329154294e-014,1.114843571696181e-013,2.117117207294805e-013,3.761834995068563e-013],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,1.727484527905284e-007,9.869639675398843e-007,3.220852106923898e-006,7.880050935794125e-006,1.605980205720019e-005,2.879217600271339e-005,4.690968458114859e-005,7.09443609828461e-005,0.0001010702474847632,0.0001370887622137449,0.0001784509086836769,0.0002243074012091213,0.0002735769131751412,0.0003250231854394265,0.0003773331027079211],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,1.688061574493246e-014,1.484732869783959e-013,7.123065332103338e-013,2.468063783855153e-012,6.907036923264598e-012,1.656839296041942e-011,3.532779020592471e-011,6.860167315754869e-011,1.234197266400998e-010,2.0833537836211e-010,3.331657703691191e-010],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,3.493755677685602e-005,0.0001570732176924437,0.0004193742352962396,0.0008635102651049066,0.00151315307394372,0.002371877464358176,0.003424444261822756,0.004640201548511866,0.005977520181392348,0.007388440310730691,0.008822969002925632,0.01023269737863458,0.0115735849020893,0.0128078877896267,0.01390529371767507,0.01484337449232333,0.01560749084647521],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,1.365609848285029e-011,1.043926720122041e-010,4.418207545619511e-010,1.367067841566119e-009,3.451331902105145e-009,7.532773028303764e-009,1.472130046229024e-008,2.636699020213358e-008,4.399407993683981e-008,6.920754762898546e-008,1.03582568140129e-007,1.485485218038232e-007,2.052789045141793e-007],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0.001758989023296,0.005859416268895077,0.0121854731500276,0.02025190882223274,0.02942180318872181,0.03904362650582194,0.04853106165769878,0.057403417005298,0.06529990611002411,0.0719774750710972,0.07729907018006912,0.081217115677444,0.08375538477886613,0.08499128485352378,0.08503974521625798,0.08403931561010483,0.08214069227267425,0.07949763667217882],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,7.219157842116184e-009,4.713739908970488e-008,1.730563837050211e-007,4.704390408669095e-007,1.054647201096337e-006,2.062671488834389e-006,3.640660620342944e-006,5.92952969094628e-006,9.050840662260549e-006,1.309471856665691e-005,1.811098272230638e-005,2.410407333393218e-005,3.103182926145628e-005,3.880776834146754e-005],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,5.542750179848574e-016,5.318313139566144e-015,2.764105502122701e-014,1.031403855273069e-013,3.092625782391725e-013,7.913064477896319e-013,1.79270871399965e-012,3.685967898755093e-012,6.999749796393263e-012,1.243762208821797e-011],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,1.738143449648588e-006,9.377271096238892e-006,2.92094154883831e-005,6.87354171023506e-005,0.0001355028577716602,0.0002360018077036386,0.0003748054244565008,0.000554040064892317,0.0007731922354631005,0.001029209735284786,0.001316828123686651,0.001629045422678626,0.001957671886188406,0.002293892703122143,0.002628795777326474,0.002953831523972344],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,4.585888571772164e-013,3.895151574455366e-012,1.813398059505209e-011,6.121046260612301e-011,1.674111680764878e-010,3.93493231066018e-010,8.239327852488073e-010,1.574109315067375e-009,2.790599482993671e-009,4.648151917631737e-009,7.343356690084273e-009,1.108543343961031e-008],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0.0002100232893815425,0.0008745178781325907,0.002182418241169944,0.004231636348405533,0.007025926601466771,0.01048907026078907,0.01448652190482309,0.01884841197368961,0.02339042636861065,0.02793085920133928,0.0323032814282509,0.03636496354457554,0.04000157177038642,0.04312882749892048,0.04569185510469492,0.0476628978482697,0.04903799328678364],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,2.873224821162242e-010,2.110577044241537e-009,8.609555089324804e-009,2.574477651144163e-008,6.296243790545133e-008,1.334032785403641e-007,2.535720122068862e-007,4.424911531868663e-007,7.2044691671594e-007,1.107485822775009e-006,1.621838502782537e-006,2.278437531889941e-006,3.087667011514901e-006],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
                           [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]])

X, Y = np.meshgrid(range(0, 21), np.arange(0, 20 + 0.1, 0.1))
Z = np.asmatrix(z)

fig = plt.figure()
ax = plt.axes(projection='3d')
surf = ax.plot_surface(X, Y, Z, cmap=cm.jet, edgecolor='black')  # for some reason the plot looks wrong (impulses)
ax.set_ylabel('y-label')
ax.set_xlabel('x-label')
ax.set_zlabel('z-label')
plt.gca().invert_yaxis()
plt.gca().invert_xaxis()


X, Y = np.meshgrid(range(0, 21), np.arange(0, 15 + 0.1, 0.1))
Z = np.asmatrix(z[0:151, :])

fig = plt.figure()
ax = plt.axes(projection='3d')
surf = ax.plot_surface(X, Y, Z, cmap=cm.jet, edgecolor='black')  # for some reason the plot looks wrong (impulses)
ax.set_ylabel('y-label')
ax.set_xlabel('x-label')
ax.set_zlabel('z-label')
plt.gca().invert_yaxis()
plt.gca().invert_xaxis()

Actual outcome
baremin

bareminsmaller

Expected outcome
I am expecting nice fins for all the data similar to the second figure. If you look carefully you can see there are some of the discrete impulses in that figure too though. None of the discrete impulses appear when I plot the data in matlab, everything looks like a fin.

Matplotlib version

  • Operating system: Windows 10
  • Matplotlib version: 2.1.2
  • Matplotlib backend (print(matplotlib.get_backend())): Qt5Agg
  • Python version: 2.7.??
  • Jupyter version (if applicable):
  • Other libraries: numpy 1.14.0

Everything was installed from anaconda.

@Nacho9216
Copy link
Author

Possible Solution
After reading some more posts I have found a solution to fix the plots. Adding 'rstride=1, cstride=1' to the 'plot_surface()' seems to generate the 3d plot correctly now.

However, I am still curious to why this addition is required, and if there is a work around for 'cmap=cm.jet' giving an error when it seems to still work? I cannot run the code in VisualStudio with the error, but it works fine in PyCharm. Thanks!

Code for reproduction

surf = ax.plot_surface(X, Y, Z, cmap=cm.jet, rstride=1, cstride=1, edgecolor='black')

New Plots

baremin_fixed

bareminsmaller_fixed

@fredrik-1
Copy link
Contributor

The main issue that you solved is probably just due to that the default sampling/interpolation that is used in the 3d ploting where to coarse for your data. rcount=100, ccount=100 also seems to work.

cmap=cm.jet works for me in python 3.6 and matplotlib 2.1.1 but cmap='jet' also works and might be a work around

@phobson
Copy link
Member

phobson commented Apr 6, 2018

a work around for 'cmap=cm.jet' giving an error when it seems to still work?

Could you elaborate on this?

@github-actions
Copy link

github-actions bot commented May 3, 2023

This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!

@github-actions github-actions bot added the status: inactive Marked by the “Stale” Github Action label May 3, 2023
@tacaswell
Copy link
Member

The source of the problem is that by default we down-sample the input data to 50 x 50 via slicing (pre 2.0 we down-sampled by a factor of 10 in all cases by default) which is to ensure that if the user passes us a 2kx2k set of data we do not have un-bounded run time for images that end up render as all edgecolor. However, in this case because the input data has a high aspect ratio ((201, 21)) so that along one direction we are not down sampling at all and the other we are going down by a factor of 4 but even so we still have more data in one direction than the other and hence more edge lines. This in turn causes there to be "vertices" in the mesh that are not at an edge line crossing. If you zoom in on the case 1 above you can see the expected "fins" are there, but because there is not a line along the ridge to connect them they show up as "kinks" in the edges of the faces rather than as several faces. I think the second case in the OP works because by resampling they are now getting lucky and the cross lines are falling on the ridges.

This data is also particularly difficult because the features are exactly 1 element wide and 0 else where.

Setting rstride=1, cstride=1 disables all of the resampling which ensure that there is always a line on the ridge.

so

I think the "fix" here is to force every "joint" in the mesh to actually be a quad vertex, but that means that we have to make a choice about which user input to ignore (as the user passes us data with a shape, if they then pass both rstride and cstride it is possible that they will pass incommensurate values). However, I would be very happy if there was a better path out of this.

I would like @scottshambaugh 's input on if this is something we should just accept as the way it is or if there is a path to actually fix this?

(also, @scottshambaugh recent improvements to the interactivity of mplot3D made this easier to debug!)

@github-actions github-actions bot removed the status: inactive Marked by the “Stale” Github Action label May 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants