@@ -50,6 +50,14 @@ define([
50
50
x_limit_to : '' ,
51
51
y_limit_from : '' ,
52
52
y_limit_to : '' ,
53
+ xticks : '' ,
54
+ xticks_label : '' ,
55
+ xticks_rotate : '' ,
56
+ removeXticks : false ,
57
+ yticks : '' ,
58
+ yticks_label : '' ,
59
+ yticks_rotate : '' ,
60
+ removeYticks : false ,
53
61
// info options
54
62
title : '' ,
55
63
x_label : '' ,
@@ -621,6 +629,8 @@ define([
621
629
let {
622
630
chartType, data, x, y, hue, setXY, userOption= '' ,
623
631
x_limit_from, x_limit_to, y_limit_from, y_limit_to,
632
+ xticks, xticks_label, xticks_rotate, removeXticks,
633
+ yticks, yticks_label, yticks_rotate, removeYticks,
624
634
title, x_label, y_label, legendPos,
625
635
useColor, color, useGrid, gridColor, markerStyle,
626
636
userCode1,
@@ -680,6 +690,56 @@ define([
680
690
681
691
let generatedCode = com_generator . vp_codeGenerator ( this , config , state , etcOptionCode . join ( ', ' ) ) ;
682
692
693
+ // Axes
694
+ if ( x_limit_from != '' && x_limit_to != '' ) {
695
+ chartCode . appendFormatLine ( "plt.xlim(({0}, {1}))" , x_limit_from , x_limit_to ) ;
696
+ }
697
+ if ( y_limit_from != '' && y_limit_to != '' ) {
698
+ chartCode . appendFormatLine ( "plt.ylim(({0}, {1}))" , y_limit_from , y_limit_to ) ;
699
+ }
700
+ if ( legendPos != '' ) {
701
+ chartCode . appendFormatLine ( "plt.legend(loc='{0}')" , legendPos ) ;
702
+ }
703
+ if ( removeXticks === true ) {
704
+ // use empty list to disable xticks
705
+ chartCode . appendLine ( "plt.xticks([])" ) ;
706
+ } else {
707
+ let xticksOptList = [ ] ;
708
+ if ( xticks && xticks !== '' ) {
709
+ xticksOptList . push ( xticks ) ;
710
+ // Not able to use xticks_label without xticks
711
+ if ( xticks_label && xticks_label != '' ) {
712
+ xticksOptList . push ( xticks_label ) ;
713
+ }
714
+ }
715
+ if ( xticks_rotate && xticks_rotate !== '' ) {
716
+ xticksOptList . push ( 'rotation=' + xticks_rotate )
717
+ }
718
+ // Add option to chart code if available
719
+ if ( xticksOptList . length > 0 ) {
720
+ chartCode . appendFormatLine ( "plt.xticks({0})" , xticksOptList . join ( ', ' ) ) ;
721
+ }
722
+ }
723
+ if ( removeYticks === true ) {
724
+ // use empty list to disable yticks
725
+ chartCode . appendLine ( "plt.yticks([])" ) ;
726
+ } else {
727
+ let yticksOptList = [ ] ;
728
+ if ( yticks && yticks !== '' ) {
729
+ yticksOptList . push ( yticks ) ;
730
+ // Not able to use xticks_label without xticks
731
+ if ( yticks_label && yticks_label != '' ) {
732
+ yticksOptList . push ( yticks_label ) ;
733
+ }
734
+ }
735
+ if ( yticks_rotate && yticks_rotate !== '' ) {
736
+ yticksOptList . push ( 'rotation=' + yticks_rotate )
737
+ }
738
+ // Add option to chart code if available
739
+ if ( yticksOptList . length > 0 ) {
740
+ chartCode . appendFormatLine ( "plt.yticks({0})" , yticksOptList . join ( ', ' ) ) ;
741
+ }
742
+ }
683
743
// Info
684
744
if ( title && title != '' ) {
685
745
chartCode . appendFormatLine ( "plt.title('{0}')" , title ) ;
@@ -690,15 +750,6 @@ define([
690
750
if ( y_label && y_label != '' ) {
691
751
chartCode . appendFormatLine ( "plt.ylabel('{0}')" , y_label ) ;
692
752
}
693
- if ( x_limit_from != '' && x_limit_to != '' ) {
694
- chartCode . appendFormatLine ( "plt.xlim(({0}, {1}))" , x_limit_from , x_limit_to ) ;
695
- }
696
- if ( y_limit_from != '' && y_limit_to != '' ) {
697
- chartCode . appendFormatLine ( "plt.ylim(({0}, {1}))" , y_limit_from , y_limit_to ) ;
698
- }
699
- if ( legendPos != '' ) {
700
- chartCode . appendFormatLine ( "plt.legend(loc='{0}')" , legendPos ) ;
701
- }
702
753
// Style - Grid
703
754
// plt.grid(True, axis='x', color='red', alpha=0.5, linestyle='--')
704
755
let gridCodeList = [ ] ;
@@ -712,7 +763,6 @@ define([
712
763
chartCode . appendFormatLine ( "plt.grid({0})" , gridCodeList . join ( ', ' ) ) ;
713
764
}
714
765
715
- let convertedData = data ;
716
766
if ( preview ) {
717
767
// Ignore warning
718
768
code . appendLine ( 'import warnings' ) ;
@@ -728,7 +778,9 @@ define([
728
778
code . appendLine ( chartCode . toString ( ) ) ;
729
779
} else {
730
780
code . appendLine ( generatedCode ) ;
731
- code . appendLine ( chartCode . toString ( ) ) ;
781
+ if ( chartCode . length > 0 ) {
782
+ code . append ( chartCode . toString ( ) ) ;
783
+ }
732
784
}
733
785
734
786
if ( userCode1 && userCode1 != '' ) {
0 commit comments