Makie outputs nothing and is sensitive to some argument changes

Hello,

I’m trying to use CairoMakie to plot some data, but there is no output or error message for my plotting. I have tried my best to reduce my problem to a MWE, but since I’m working with a particular set of data, this is difficult (coming from integrating some differential equations)…

If I run this code, I get no plot, and no error message… which makes it difficult to debug.

fig = Figure(size = (1000, 300))

data = loadData()

ax =  Axis(fig[1, 1], limits = (0, 2, 0, 2))
	
x = log10.(data[2, :])
y = log10.(data[1, :])
c = 1:length(x)

lines!(ax, x, y; color = c)

fig

The problem disappears after removing some elements. Namely, a plot is produced if, while keeping everything else the same, I do one of the following:

  1. remove the color kwarg in the lines! method
  2. remove the limits argument in the Axis method
  3. remove the log10 function on one of the sets of data

For example, removing the limits argument works just fine:

I am very puzzled by this outcome. Maybe there is something I am overlooking? What does it mean for Makie to output nothing?

I thought that maybe the data was weird, and it was causing some issue when plotting, but this is what I am trying to plot:

fig = Figure()

ax1 = Axis(fig[1, 1])
ax2 = Axis(fig[2, 1])

lines!(ax1, log10.(data[1, :]))
lines!(ax2, log10.(data[2, :]))

fig

Which does not seem pathological. I have not managed to reproduce this with some other data. But perhaps someone knows what is causing this issue.

Anything helps!

Thanks!

1 Like

Strange, could you share the raw data in a github gist or so? My first guess would have been an Inf in the input data due to the log10 but it seems you can plot each component individually…

If I run this code, I get no plot, and no error message

This happens sometimes in CairoMakie if some invalid data makes it through the low-level API and Cairo then just gives up on that. That’s why I was guessing Inf

Is it literally nothing, or is it an empty plot? Perhaps save("test.svg", fig) and paste the output here? If that doesn’t work, what is typeof(fig)?

Given the things that allow you to see an output, my guess would be that you are restricting your plot to a range and color of data that is just difficult to see.

Given your limits argument, I’d except to just see

But given your color argument, I’d expect it to be in the yellow/green range of viridis for that range of the line, assuming points are evenly spaced. What are you seeing?

Good point, I realize that I had a typo in my save function at some point, but now it gives an error when I use it properly:

BoundsError: attempt to access 388-element Vector{Float32} at index [[14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, 400, 401]]

Stacktrace:
  [1] throw_boundserror(A::Vector{Float32}, I::Tuple{Vector{Int64}})
  ...

But only when I use the limits argument. Not sure why it would cause such an error…

Indeed, I think there is no Inf in my data, but I can try putting it online somehow, if this last error message is not revealing enough.

The data would make it easiest to reproduce and find a fix

Ok, here is the data

1.0	2.0287420082308714	3.077225814377075	4.145816121223692	5.234917030558265	6.344900575861257	7.47619058669651	8.62916860846601	9.804281291888802	11.001918439485767	12.222531284739388	13.466553521758053	14.734430982415022	16.02664402820663	17.343630617578242	18.685896378451954	20.05388201736322	21.448099039457617	22.86907185282278	24.31728364173166	25.79329477851359	27.297578898460852	28.8307029378187	30.39324210244804	31.985719900312663	33.60876530883949	35.262885274600855	36.94871369687196	38.66684304371368	40.417897365116055	42.20248635506802	44.02124774345359	45.874825051702466	47.76386784188038	49.6890180267934	51.6509326918611	53.65025510204661	55.687607197433316	57.763570717338126	59.87864764871308	62.03319216556321	64.22728008540348	66.46046304745907	68.73128850335752	71.03633538037944	73.36824174936342	75.71161693843021	78.03438072963738	80.26931062528183	82.2747719467133	83.75296990797536	84.09012711769192	82.11454832447598	75.9522329419383	63.87815955488353	46.801694596002086	29.592352064139003	16.818353247200932	9.230776442225464	5.265244903722985	3.313893062873893	2.380028665625993	1.9440193629809623	1.750201093280391	1.6781201059361492	1.6670502308217794	1.6879093977881665	1.7260394644887123	1.7742170336141756	1.828269590328565	1.885948821454526	1.9463044411158863	2.0085772217296647	2.072316809528873	2.1374064488917517	2.203510245709526	2.2706652075316076	2.3386505921117915	2.4074329346124586	2.47697563299386	2.5470478163724715	2.61778340485667	2.688905479226288	2.760420117395235	2.832376202721019	2.9043803684253637	2.9765942491302644	3.048991175711755	3.1211777442224706	3.193306155466222	3.2653764094430113	3.3369910856260137	3.408234863321223	3.479128759552328	3.549480400771093	3.619065217424708	3.687993906956868	3.7562664693675725	3.823543051574012	3.889800123827152	3.9550961088742276	4.01943100671524	4.082505828521231	4.144255731237196	4.204765607177373	4.264035456341762	4.322009478519779	4.378298232376678	4.4331300315655335	4.486504876086342	4.5384227659391065	4.588883701123825	4.637428066843535	4.684396131506552	4.729801976433005	4.773645601622893	4.815927007076217	4.856646192792977	4.895347752075844	4.932491798594272	4.9681426839651905	5.0023004081885984	5.034964971264497	5.066136373192887	5.095814613973765	5.123755670515229	5.149995217986008	5.175031512822062	5.198864555023393	5.22149434459	5.242920881521884	5.263144165819043	5.28216419748148	5.299980976509193	5.316594502902182	5.331670676038196	5.345828415049805	5.359197444745424	5.371777765125053	5.383569376188691	5.39457227793634	5.4047864703679975	5.414211953483666	5.422848727283344	5.430696791767033	5.437565943362778	5.443910079531997	5.449867369898124	5.4554378144611615	5.460621413221109	5.465418166177965	5.4698280733317315	5.473851134682408	5.4774873502299934	5.480736719974489	5.4835992439158945	5.486074922054209	5.488066158573999	5.48993114738056	5.491671509495856	5.493287244919889	5.494778353652658	5.496144835694165	5.497386691044407	5.498503919703386	5.499496521671101	5.500364496947553	5.501107845532741	5.501726567426665	5.502220662629327	5.502590131140724	5.502806301367913	5.502996176266931	5.50317088764607	5.50333043550533	5.50347481984471	5.503604040664211	5.503718097963834	5.503816991743577	5.50390072200344	5.503969288743424	5.50402269196353	5.504060931663757	5.504084007844104	5.504091920504572	5.50408466964516	5.504062255265871	5.504024677366701	5.503971935947653	5.503904031008725	5.503824500618251	5.503750974308853	5.503679686098436	5.503610635986999	5.503543823974543	5.503479250061068	5.503416914246573	5.503356816531059	5.503298956914525	5.503243335396972	5.503189951978399	5.503138806658806	5.503089899438195	5.503043230316564	5.502998799293913	5.502956606370243	5.502916651545553	5.502878934819845	5.502843456193116	5.5028102156653675	5.5027792132366	5.502750448906813	5.502723922676006	5.5026996345441805	5.502677584511336	5.502657772577471	5.502640198742586	5.502624863006682	5.502611765369759	5.502600905831816	5.502592284392854	5.502585901052872	5.502581755811871	5.50257984866985	5.50258017962681	5.502583157211522	5.50258745449805	5.502591683388737	5.502595843883586	5.502599935982593	5.502603959685761	5.502607914993088	5.502611801904575	5.5026156204202215	5.502619370540027	5.502623052263994	5.50262666559212	5.502630210524406	5.502633687060851	5.5026370952014565	5.502640434946222	5.502643706295147	5.502646909248232	5.502650043805477	5.5026531099668805	5.502656107732445	5.502659037102169	5.502661898076052	5.502664690654096	5.502667414836299	5.502670070622663	5.502672658013185	5.502675177007868	5.50267762760671	5.502680009809713	5.502682323616875	5.5026845690281965	5.502686746043678	5.50268885466332	5.50269089488712	5.502692866715082	5.502694770147202	5.502696605183483	5.502698371823923	5.502700070068523	5.502701699917283	5.502703261370202	5.502704754427282	5.502706179088522	5.50270753535392	5.502708823223479	5.502710042697198	5.502711193775077	5.502712276457115	5.502713290743312	5.50271423663367	5.502715114128188	5.502715923226865	5.502716663929702	5.5027173362366995	5.502717940147856	5.502718475663173	5.502718942782648	5.5027193415062845	5.502719671834081	5.502719933766036	5.502720127302151	5.502720252442427	5.502720309186862	5.502720297535457	5.502720217488211	5.502720069045125	5.5027198522062	5.50271949255518	5.502718772326965	5.5027180605499675	5.502717357224188	5.502716662349626	5.502715975926281	5.502715297954155	5.502714628433246	5.502713967363555	5.502713314745081	5.502712670577824	5.502712034861786	5.502711407596965	5.502710788783362	5.502710178420976	5.502709576509808	5.502708983049858	5.502708398041125	5.50270782148361	5.502707253377312	5.502706693722232	5.50270614251837	5.502705599765726	5.502705065464299	5.502704539614089	5.502704022215097	5.502703513267323	5.502703012770767	5.502702520725428	5.502702037131306	5.502701561988403	5.502701095296717	5.502700637056249	5.502700187266998	5.5026997459289655	5.502699313042149	5.5026988886065515	5.502698472622171	5.502698065089009	5.502697666007064	5.502697275376337	5.502696893196827	5.502696519468535	5.502696154191461	5.502695797365604	5.5026954489909645	5.5026951090675436	5.502694777595339	5.502694454574353	5.502694140004585	5.502693833886034	5.5026935362187	5.502693247002584	5.502692966237687	5.502692693924006	5.502692430061543	5.502692174650298	5.502691927690271	5.502691689181461	5.502691459123868	5.502691237517493	5.502691024362337	5.502690819658397	5.502690623405675	5.502690435604171	5.502690256253884	5.502690085354816	5.502689922906964	5.50268976891033	5.5026896233649145	5.502689486270716	5.502689357627736	5.502689237435972	5.502689125695427	5.502689022406099	5.502688927567989	5.502688841181096	5.502688763245421	5.502688693760963	5.5026886327277245	5.502688580145702	5.502688536014897	5.502688500335311	5.502688473106941	5.50268845432979	5.502688444003856	5.5026884421291395	5.502688448705641	5.50268846373336	5.502688487212296	5.502688519142451	5.502688559523823	5.502688608356412	5.502688665640219	5.502688731375244	5.502688805561486	5.502688888198946	5.5026889792876235	5.502689078827519	5.502689186818632	5.502689303260962	5.50268942815451	5.502689561499277	5.5026897032952595	5.502689853542461	5.50269001224088	5.502690179390515	5.502690354991369
0.01	0.010993604401384824	0.01295312815174014	0.01585354845881063	0.01967093375960122	0.024387325357833126	0.029987145873857306	0.036462310522448714	0.043809364315532846	0.05203419374845856	0.061149339191170875	0.07118033603162977	0.08216208404596578	0.0941478577348292	0.10720419276782056	0.1214184341057587	0.13689785184080402	0.15377710730986113	0.1722385421616811	0.1924921814339529	0.21481251168228582	0.23951615607671325	0.2670150997596866	0.2978667484720387	0.33271550542435213	0.3724830549430127	0.4182144873821915	0.4714136365333229	0.534052830665183	0.6087843605272618	0.6992542212937722	0.8105401344777386	0.9499985496001417	1.1282637929214747	1.360880047846142	1.6718748726464063	2.098594074437386	2.700544870391327	3.5755812989639515	4.8880719929797785	6.923760710065064	10.190067543369379	15.61614300189527	24.942844208124434	41.5181704895341	71.93278077741049	129.42157940516068	241.07765444441696	463.2064130354118	913.9578749215804	1841.1112605325281	3753.808486165865	7617.466278004039	14945.97057931777	27010.269729236712	42662.50849327642	57355.88510439323	67137.06279906434	71675.45816801036	72692.12975133864	71829.50724616836	70085.75555031965	67975.67782835655	65749.28380049451	63521.617901704514	61347.93558134485	59252.05284478456	57243.414364261276	55324.64971874024	53495.25624704355	51752.17263639484	50093.3376642021	48514.06023356413	47012.1691979636	45582.688586193275	44223.95872048915	42930.642148008796	41702.01423085935	40532.4795009982	39421.49720777471	38364.83955266106	37359.89773287728	36406.126131492965	35498.35790196923	34636.08894702211	33817.848360384356	33039.2081341942	32300.30029239639	31599.39854283222	30932.673751250113	30300.125917650064	29701.218877823914	29131.632095964556	28591.22314739635	28080.28592719235	27595.348516696995	27134.998709271833	26699.236504916866	26288.144384775343	25897.897555173877	25528.03182124419	25178.547182986273	24849.76017927759	24538.204055464932	24243.17237103655	23964.665125992444	23702.92195370136	23457.04390256785	23224.14289534229	23004.21893202469	22797.27201261504	22603.302137113347	22422.719330757733	22251.90064931863	22090.77732092889	21939.3493455885	21797.61672329746	21665.579454055773	21544.016946127333	21429.383595035746	21321.39796703364	21220.060062121025	21125.369880297894	21037.32742156425	20955.93268592009	20881.874542148656	20813.74274776359	20749.534796966178	20689.250689756416	20632.89042613431	20580.45400609985	20531.941429653052	20487.352696793903	20446.687807522405	20409.94676183856	20377.69720617488	20347.745691106174	20319.74035785692	20293.68120642711	20269.568236816747	20247.40144902583	20227.180843054357	20208.906418902334	20192.578176569754	20178.19611605662	20166.099208011656	20155.077121050283	20144.814491350837	20135.311318913307	20126.567603737705	20118.583345824023	20111.358545172265	20104.89320178243	20099.18731565452	20094.240886788528	20090.05391518446	20086.626400842313	20084.076064856512	20081.714494066946	20079.53882421708	20077.549055306914	20075.745187336444	20074.127220305676	20072.69515421461	20071.44898906324	20070.38872485157	20069.514361579604	20068.82589924733	20068.323337854763	20068.006677401892	20067.875917888723	20067.943841226006	20068.03167137216	20068.126155289563	20068.227292978223	20068.335084438135	20068.449529669302	20068.57062867172	20068.698381445396	20068.832787990323	20068.9738483065	20069.121562393935	20069.27593025262	20069.436951882562	20069.604627283756	20069.778956456204	20069.959939399905	20070.147576114858	20070.341866601066	20070.54281085853	20070.73907405182	20070.90165168609	20071.058850387617	20071.210670156397	20071.357110992434	20071.498172895725	20071.633855866272	20071.764159904076	20071.88908500913	20072.008631181445	20072.122798421013	20072.231586727834	20072.334996101912	20072.433026543244	20072.525678051832	20072.612950627677	20072.694844270776	20072.77135898113	20072.842494758737	20072.908251603603	20072.968629515723	20073.023628495095	20073.073248541725	20073.11748965561	20073.15635183675	20073.189835085148	20073.217939400798	20073.240664783705	20073.258011233866	20073.269978751283	20073.276567335954	20073.27777698788	20073.273607707062	20073.2640594935	20073.24913234719	20073.23112472504	20073.215425693194	20073.200022933277	20073.1849164453	20073.170106229256	20073.155592285148	20073.141374612977	20073.127453212735	20073.11382808443	20073.100499228065	20073.08746664363	20073.07473033113	20073.062290290563	20073.050146521935	20073.03829902524	20073.02674780048	20073.015492847655	20073.004534166765	20072.993871757808	20072.98350562079	20072.973435755703	20072.96366216255	20072.954184841336	20072.945003792054	20072.936119014706	20072.927530509296	20072.91923827582	20072.911242314276	20072.90354262467	20072.896139206998	20072.88903206126	20072.882221187458	20072.87570658559	20072.869488255656	20072.86356619766	20072.857940411595	20072.852610897466	20072.847577655273	20072.842840685014	20072.83839998669	20072.8342555603	20072.830407405847	20072.826855523326	20072.823599912743	20072.820640574093	20072.817977507377	20072.815610712598	20072.813540189753	20072.81176593884	20072.810287959866	20072.809106252826	20072.808220817722	20072.80763165455	20072.807338763312	20072.807342144013	20072.807641796644	20072.808237721212	20072.809129917718	20072.810318386157	20072.81180312653	20072.813584138836	20072.81566142308	20072.818034979256	20072.820704807367	20072.823670907415	20072.826933279397	20072.830491923312	20072.834346839165	20072.83821847743	20072.840922451498	20072.84359080288	20072.84622353159	20072.848820637613	20072.85138212096	20072.853907981626	20072.856398219614	20072.858852834917	20072.861271827547	20072.863655197492	20072.86600294476	20072.868315069347	20072.870591571253	20072.87283245048	20072.87503770703	20072.877207340895	20072.879341352083	20072.88143974059	20072.883502506418	20072.885529649568	20072.887521170036	20072.889477067823	20072.891397342933	20072.893281995362	20072.89513102511	20072.89694443218	20072.89872221657	20072.90046437828	20072.902170917307	20072.903841833657	20072.905477127326	20072.907076798318	20072.908640846625	20072.910169272258	20072.911662075207	20072.913119255478	20072.914540813068	20072.915926747977	20072.91727706021	20072.91859174976	20072.91987081663	20072.921114260822	20072.922322082333	20072.923494281164	20072.924630857317	20072.92573181079	20072.92679714158	20072.927826849693	20072.928820935125	20072.929779397877	20072.930702237947	20072.93158945534	20072.932441050052	20072.933257022087	20072.93403737144	20072.934782098113	20072.935491202104	20072.93616468342	20072.93680254205	20072.937404778004	20072.93797139128	20072.938502381872	20072.93899774979	20072.93945749502	20072.939881617574	20072.94027011745	20072.940622994643	20072.94094024916	20072.941221880996	20072.94146789015	20072.941678276624	20072.94185304042	20072.941992181535	20072.94209569997	20072.942163595726	20072.942195868804	20072.942192519196	20072.942153546916	20072.94207895195	20072.941968734307	20072.941822893983	20072.941641430978	20072.941424345296	20072.941171636932	20072.94088330589	20072.940559352166	20072.940199775763	20072.939804576683	20072.939373754918	20072.938907310476	20072.938405243356	20072.93786755355	20072.93729424107	20072.936685305907	20072.936040748067	20072.935360567546	20072.934644764344	20072.933893338464	20072.933106289904	20072.932283618662	20072.93142532474	20072.93053140814	20072.92960186886	20072.9286367069	20072.92763592226	20072.92659951494	20072.92552748494

I’ve also put it here:

I can reproduce this error, using the following code:

using CairoMakie, DelimitedFiles

fig = Figure()

data = readdlm("sample_data.csv")

ax = Axis(fig[1, 1], limits = (0, 2, 0, 2))

x = log10.(data[2, :])
y = log10.(data[1, :])
c = 1:length(x)

lines!(ax, x, y; color=c)
save("test.svg", fig)

Producing: ERROR: LoadError: BoundsError: attempt to access 16-element Vector{Float32} at index [[33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 47]]

Error on the axis line! You forgot to close the parenthesis ax = Axis(…

1 Like

yep sorry! Fixed it.

I get no errors running the above code after downloading sample_data.csv, and it seems to correctly save an .svg with the correct look (I had to convert the svg to png to upload the image below):
test

I’m running Julia 1.11.0 on linux, with CairoMakie v0.12.13

Ok, so it does work with the newer version. I was using CairoMakie v0.12.9.

It seems like it was a problem with a previous version?

Thanks for the help, everyone!