@@ -270,7 +270,7 @@ def transform(
270270 / (oldrangemax - oldrangemin )
271271 ) + newrangemin
272272
273- def _draw_ticks (self , x : int , y : int ) -> None :
273+ def _draw_ticks (self , x : int , y : int , ticksx = None , ticksy = None ) -> None :
274274 """
275275 Draw ticks in the plot area
276276
@@ -281,38 +281,58 @@ def _draw_ticks(self, x: int, y: int) -> None:
281281
282282 """
283283
284- ticks = np .array ([10 , 30 , 50 , 70 , 90 ])
285- subticks = np .array ([20 , 40 , 60 , 80 ])
286- ticksxnorm = np .array (self .transform (0 , 100 , np .min (x ), np .max (x ), ticks ))
287- ticksynorm = np .array (self .transform (0 , 100 , np .min (y ), np .max (y ), ticks ))
284+ ticks_dummy = np .array ([10 , 30 , 50 , 70 , 90 ])
285+ subticks_dummy = np .array ([20 , 40 , 60 , 80 ])
286+
287+ if ticksx is None :
288+ ticksxnorm = np .array (
289+ self .transform (0 , 100 , np .min (x ), np .max (x ), ticks_dummy )
290+ )
291+ subticksxnorm = np .array (
292+ self .transform (0 , 100 , np .min (x ), np .max (x ), subticks_dummy )
293+ )
294+ else :
295+ ticksxnorm = np .array (ticksx )
296+
297+ if ticksy is None :
298+ ticksynorm = np .array (
299+ self .transform (0 , 100 , np .min (y ), np .max (y ), ticks_dummy )
300+ )
301+ subticksynorm = np .array (
302+ self .transform (0 , 100 , np .min (y ), np .max (y ), subticks_dummy )
303+ )
304+ else :
305+ ticksynorm = np .array (ticksy )
288306
289- subticksxnorm = np .array (self .transform (0 , 100 , np .min (x ), np .max (x ), subticks ))
290- subticksynorm = np .array (self .transform (0 , 100 , np .min (y ), np .max (y ), subticks ))
291307
292308 ticksxrenorm = np .array (
293309 self .transform (
294310 np .min (x ), np .max (x ), self ._newxmin , self ._newxmax , ticksxnorm
295311 ),
296312 dtype = np .int16 ,
297313 )
314+
315+
298316 ticksyrenorm = np .array (
299317 self .transform (
300318 np .min (y ), np .max (y ), self ._newymin , self ._newymax , ticksynorm
301319 ),
302320 dtype = np .int16 ,
303321 )
304- subticksxrenorm = np .array (
305- self .transform (
306- np .min (x ), np .max (x ), self ._newxmin , self ._newxmax , subticksxnorm
307- ),
308- dtype = np .int16 ,
309- )
310- subticksyrenorm = np .array (
311- self .transform (
312- np .min (y ), np .max (y ), self ._newymin , self ._newymax , subticksynorm
313- ),
314- dtype = np .int16 ,
315- )
322+ if ticksx is None :
323+ subticksxrenorm = np .array (
324+ self .transform (
325+ np .min (x ), np .max (x ), self ._newxmin , self ._newxmax , subticksxnorm
326+ ),
327+ dtype = np .int16 ,
328+ )
329+ if ticksy is None :
330+ subticksyrenorm = np .array (
331+ self .transform (
332+ np .min (y ), np .max (y ), self ._newymin , self ._newymax , subticksynorm
333+ ),
334+ dtype = np .int16 ,
335+ )
316336 for i , tick in enumerate (ticksxrenorm ):
317337 draw_line (
318338 self ._plotbitmap ,
@@ -345,24 +365,28 @@ def _draw_ticks(self, x: int, y: int) -> None:
345365 tick ,
346366 (1.0 , 0.5 ),
347367 )
348- for tick in subticksxrenorm :
349- draw_line (
350- self ._plotbitmap ,
351- tick ,
352- self ._newymin ,
353- tick ,
354- self ._newymin - self ._tickheightx // 2 ,
355- 2 ,
356- )
357- for tick in subticksyrenorm :
358- draw_line (
359- self ._plotbitmap ,
360- self ._newxmin ,
361- tick ,
362- self ._newxmin + self ._tickheighty // 2 ,
363- tick ,
364- 2 ,
365- )
368+
369+ if ticksx is None :
370+ for tick in subticksxrenorm :
371+ draw_line (
372+ self ._plotbitmap ,
373+ tick ,
374+ self ._newymin ,
375+ tick ,
376+ self ._newymin - self ._tickheightx // 2 ,
377+ 2 ,
378+ )
379+
380+ if ticksy is None :
381+ for tick in subticksyrenorm :
382+ draw_line (
383+ self ._plotbitmap ,
384+ self ._newxmin ,
385+ tick ,
386+ self ._newxmin + self ._tickheighty // 2 ,
387+ tick ,
388+ 2 ,
389+ )
366390
367391 if self ._tickgrid :
368392 self ._draw_gridx (ticksxrenorm )
0 commit comments