Build crashing on launch - google-play-games

I implemented the google play game services to my game for leaderboards and achievements, my game builds normally, but when I try to launch it on android, it crashes before the unity splash logo shows, logcat gives me this:
com.FarSouth.RocketJumper/com.unity3d.player.UnityPlayerActivity
03-03 16:48:59.617 2993 2993 D ActivityManager: starting Active launch
03-03 16:48:59.648 2993 5385 I ActivityManager: START u0 {act=android.intent.action.MAIN typ=null flg=0x10200000 cmp=ComponentInfo{com.FarSouth.RocketJumper/com.unity3d.player.UnityPlayerActivity}} from uid 10077
03-03 16:48:59.665 2993 3769 I ActivityManager: DSS on for com.FarSouth.RocketJumper and scale is 0.75
03-03 16:48:59.702 2993 3628 D ActivityManager: isScaleDownAnimationEnabled() : false
03-03 16:48:59.702 2993 3628 D ActivityManager: applyOptionsLocked, ANIM_CUSTOM_SCALE_UP, x : 803, y : 879, isHomeItem : false
03-03 16:48:59.702 2993 3628 D ActivityManager: applyOptionsLocked, ANIM_CUSTOM_SCALE_UP, task.getRootActivity() : ActivityRecord{f3e35f2 u0 com.FarSouth.RocketJumper/com.unity3d.player.UnityPlayerActivity t21599}, task.getTaskToReturnTo() : 1
03-03 16:48:59.702 2993 3628 D ActivityManager: setAppIconInfo(), x : 803, y : 879, width : 251, height : 312, isHomeItem : false
03-03 16:48:59.704 2993 3628 I ActivityManager: Config changes=480 {0 1.0 themeSeq = 0 showBtnBg = 0 206mcc10mnc [pt_BR,fr_BE] ldltr sw360dp w640dp h336dp 480dpi nrml long land finger -keyb/v/h -nav/h appBounds=Rect(0, 0 - 1920, 1080) s.21}
03-03 16:48:59.724 2993 3628 I ActivityManager: Override config changes=480 {0 1.0 themeSeq = 0 showBtnBg = 0 206mcc10mnc [pt_BR,fr_BE] ldltr sw360dp w640dp h336dp 480dpi nrml long land finger -keyb/v/h -nav/h appBounds=Rect(0, 0 - 1920, 1080) s.21} for displayId=0
03-03 16:48:59.762 2993 3314 D ActivityManager: package com.samsung.android.game.gametools, user - 0 is SDcard whitelisted
03-03 16:48:59.775 2993 3314 I ActivityManager: Start proc 32163:com.samsung.android.game.gametools/u0a27 for service com.samsung.android.game.gametools/.floatingui.service.external.GameToolsIntentService
03-03 16:48:59.781 2993 5473 W ActivityManager: crash : com.FarSouth.RocketJumper,0
03-03 16:48:59.795 2993 5473 W ActivityManager: Force finishing activity com.FarSouth.RocketJumper/com.unity3d.player.UnityPlayerActivity
03-03 16:48:59.817 2993 5385 I ActivityManager: DSS on for com.samsung.android.game.gametools and scale is 1.0
03-03 16:48:59.857 2993 3628 I ActivityManager: Config changes=480 {0 1.0 themeSeq = 0 showBtnBg = 0 206mcc10mnc [pt_BR,fr_BE] ldltr sw360dp w360dp h616dp 480dpi nrml long port finger -keyb/v/h -nav/h appBounds=Rect(0, 0 - 1080, 1920) s.22}
03-03 16:48:59.884 2993 3628 I ActivityManager: Override config changes=480 {0 1.0 themeSeq = 0 showBtnBg = 0 206mcc10mnc [pt_BR,fr_BE] ldltr sw360dp w360dp h616dp 480dpi nrml long port finger -keyb/v/h -nav/h appBounds=Rect(0, 0 - 1080, 1920) s.22} for displayId=0
03-03 16:48:59.914 2993 3027 I ActivityManager: Showing crash dialog for package com.FarSouth.RocketJumper u0
03-03 16:48:59.995 2993 5329 D PackageManager: getSelectedMetaData : packageName(com.FarSouth.RocketJumper) or Metadata strings {[Ljava.lang.String;#b99c7e3}
03-03 16:49:00.307 2993 3026 W ActivityManager: Activity pause timeout for ActivityRecord{f3e35f2 u0 com.FarSouth.RocketJumper/com.unity3d.player.UnityPlayerActivity t21599 f}
03-03 16:49:00.313 2993 3026 D ActivityManager: isScaleDownAnimationEnabled() : true
03-03 16:49:00.313 2993 3026 D ActivityManager: clearAppIconInfo()
03-03 16:49:00.313 2993 3026 D ActivityManager: applyOptionsLocked, ANIM_CUSTOM_SCALE_DOWN
03-03 16:49:00.343 2993 5329 D ActivityManager: post active user change for 0 fullscreen true isHomeActivity() true
I don't have any experience with crash logs but it seems that its either Android Game Tools or Unity Player Activity that's crashing my game? Before adding the GPGS to my game it worked normally. Thanks in advance.

I know that GPGS let your game crash with an IllegalStateException if you don't set its ID. I assume that's the case here, although I can't see it in your log.

dou you have Admob SDK in your game? GPGS and Admob did not work well together. Maybe use a older Version of GPGS the newest version makes often problems.

Related

How to capture windows 10/windows 11 advanced display settings for multiple monitors

I am trying to capture the following displays information connected to my laptop programatically using powershell but I am unable to find a way. This information can be found via the windows GUI at Settings > Display > Advanced Display Information (2 screenshots attached below).
Here's the information I am trying to capture
Display Name: (In this case, display name for internal would be but the external one would be "ASUS VP 228)
Display Resolution: 1680x1050 and 1920x1080 for the 2 displays
Whether it's an internal/external display: True and False
Refresh rate: 60Hz and 60Hz
Here's what I've tried
Get-WmiObject win32_videocontroller
Returns the resolution under parameter VideoModeDescription but even then, it seems to return the value of "Active Signal Resolution" (from the screenshot) below).
Get-WmiObject Win32_Desktopmonitor
DeviceID : DesktopMonitor1
DisplayType :
MonitorManufacturer : (Standard monitor types)
Name : Generic PnP Monitor
ScreenHeight :
ScreenWidth :
Only get output information for 1 out of the 2 monitors and don't get ScreenHeight or ScreenWidth` values.
get-ciminstance -namespace root\wmi -classname wmimonitorbasicdisplayparams
Active : True
DisplayTransferCharacteristic : 120
InstanceName : DISPLAY\IVO8C66\5&462698&0&UID256_0
MaxHorizontalImageSize : 31
MaxVerticalImageSize : 17
SupportedDisplayFeatures : WmiMonitorSupportedDisplayFeatures
VideoInputType : 1
PSComputerName :
Active : True
DisplayTransferCharacteristic : 120
InstanceName : DISPLAY\ACI22C3\5&462698&0&UID265_0
MaxHorizontalImageSize : 48
MaxVerticalImageSize : 27
SupportedDisplayFeatures : WmiMonitorSupportedDisplayFeatures
VideoInputType : 1
PSComputerName
Gives me the correct monitor count but doesn't give me any other information.
I then tried using the DumpEDID tool and it gave me more information but didn't give me current monitor resolution or whether it's an internal display or not.
DumpEDID v1.07
Copyright (c) 2006 - 2018 Nir Sofer
Web site: http://www.nirsoft.net
*****************************************************************
Active : Yes
Registry Key : DISPLAY\ACI22C3\5&462698&0&UID265
Monitor Name : ASUS VP228
Serial Number : G6LMTF155938
Manufacture Week : 26 / 2016
ManufacturerID : 26884 (0x6904)
ProductID : 8899 (0x22C3)
Serial Number (Numeric) : 155938 (0x00026122)
EDID Version : 1.3
Display Gamma : 2.20
Vertical Frequency : 50 - 75 Hz
Horizontal Frequency : 24 - 83 KHz
Maximum Image Size : 48 X 27 cm (21.7 Inch)
Maximum Resolution : 1920 X 1080
Support Standby Mode : No
Support Suspend Mode : No
Support Low-Power Mode : Yes
Support Default GTF : No
Digital : Yes
Supported Display Modes :
720 X 400 70 Hz
640 X 480 60 Hz
640 X 480 67 Hz
640 X 480 72 Hz
640 X 480 75 Hz
800 X 600 56 Hz
800 X 600 60 Hz
800 X 600 72 Hz
800 X 600 75 Hz
832 X 624 75 Hz
1024 X 768 60 Hz
1024 X 768 70 Hz
1024 X 768 75 Hz
1280 X 720 60 Hz
1152 X 864 75 Hz
1280 X 960 60 Hz
1440 X 900 60 Hz
1280 X 1024 60 Hz
1280 X 1024 75 Hz
1680 X 1050 60 Hz
1920 X 1080 60 Hz
*****************************************************************
*****************************************************************
Active : Yes
Registry Key : DISPLAY\IVO8C66\5&462698&0&UID256
Manufacture Week : 0 / 2019
ManufacturerID : 53030 (0xCF26)
ProductID : 35942 (0x8C66)
Serial Number (Numeric) : 0 (0x00000000)
EDID Version : 1.4
Display Gamma : 2.20
Maximum Image Size : 31 X 17 cm (13.9 Inch)
Maximum Resolution : 1920 X 1080
Support Standby Mode : No
Support Suspend Mode : No
Support Low-Power Mode : No
Support Default GTF : No
Digital : Yes
Supported Display Modes :
1920 X 1080 60 Hz
The script here gives me almost what I want except it doesn't give me the monitor name nor does it give me information whether it's internal or not.
I have attached 2 screenshots from the Settings > Display > Advanced Display page which is the information I am looking to capture.

X11 (xorg) fails to set/change resolution (linux x86)

I'm trying to get a 10-inch touch display (native resolution: 1280x800) to switch to 1024x768, but everything I try is either ignored or results in an error. The display reportedly supports the resolution, though, xrandr --verbose reports (I'm using the default VESA driver):
xrandr: Failed to get size of gamma for output default
Screen 0: minimum 640 x 480, current 640 x 480, maximum 1280 x 800
default connected 640x480+0+0 (0x180) normal (normal) 0mm x 0mm
Identifier: 0x17d
Timestamp: 635022581
Subpixel: horizontal rgb
Clones:
CRTC: 0
CRTCs: 0
Transform: 1.000000 0.000000 0.000000
0.000000 1.000000 0.000000
0.000000 0.000000 1.000000
filter:
1280x800 (0x17e) 0.0MHz
h: width 1280 start 0 end 0 total 1280 skew 0 clock 0.0KHz
v: height 800 start 0 end 0 total 800 clock 0.0Hz
800x600 (0x17f) 0.0MHz
h: width 800 start 0 end 0 total 800 skew 0 clock 0.0KHz
v: height 600 start 0 end 0 total 600 clock 0.0Hz
640x480 (0x180) 0.0MHz *current
h: width 640 start 0 end 0 total 640 skew 0 clock 0.0KHz
v: height 480 start 0 end 0 total 480 clock 0.0Hz
1024x768 (0x181) 0.0MHz
h: width 1024 start 0 end 0 total 1024 skew 0 clock 0.0KHz
v: height 768 start 0 end 0 total 768 clock 0.0Hz
If I try to change the resolution via xrandr --output default --mode 1027x768, i just get:
xrandr: Failed to get size of gamma for output default
xrandr: Configure crtc 0 failed
As far as I can see, only the second line is relevant to my problem; I don't know why xrandr would want to configre crtc 0, though, I only have the touch screen connected.
Failing that, I tried to configure the mode directly using the following xorg.conf:
Section "InputClass"
Identifier "calibration"
MatchProduct "DIALOGUE INC PenMount USB"
Option "Calibration" "95 911 93 919"
Option "SwapAxes" "0"
EndSection
Section "Monitor"
Identifier "disp0"
Modeline "1024x768_60.00" 63.50 1024 1072 1176 1328 768 771 775 798 -hsync +vsync
Option "PreferredMode" "1024x768_60.00"
EndSection
Section "Device"
Identifier "card0"
Driver "vesa"
EndSection
Section "Screen"
Identifier "src0"
Device "card0"
Monitor "disp0"
SubSection "Display"
Modes "1024x768_60.00" "1024x768"
EndSubSection
EndSection
Unfortunately, This doesn't work, either Xorg.log shows the following:
[634043.694] (II) VESA(0): Not using mode "1024x768_60.00" (no mode of this name)
[634043.694] (II) VESA(0): Not using built-in mode "1024x768" (no mode of this name)
Why doesn't this work? And what else can I try to get the display to switch to 1024x768?
I've uploaded the full logfile to Pastebin.
You can try to perform the following actions
cvt -r 1024 768
xrandr --newmode "1024x768_60.00" 63.50 1024 1072 1176 1328 768 771 775 798 -hsync +vsync
xrandr --addmode default 1024x768_60.00
xrandr --output default --mode 1024x768_60.00

Gnuplot gives 2 instead of 24 columns with an other timeformat

I have the next problem. I had an datafile like;
1412481600,304,0,0,0,304,0
1412485200,385,0,0,0,383,0
1412488800,332,0,0,0,331,0
1412492400,359,0,0,0,355,0
I have changed the format to;
08-11-2014-17:00,390,0,27,417
08-11-2014-18:00,474,0,0,474
08-11-2014-19:00,467,0,0,467
08-11-2014-20:00,687,0,0,687
I changed either the gnuplotscript.
First was;
set timefmt x "%s"
To now in;
set timefmt x "%d-%m-%Y-%H:%M"
In the new situation gnuplot gives me 2 columns they are overwrite
with other columns.
What am I doing wrong or I forget ?
Here the working en wrong example;
And this is the complete code;
file = 'uur.txt'
set output "dag.png"
set datafile separator ","
set linestyle 1 lt 1 lc rgb "black"
set bmargin 5 # witruimte onder grafiek
set boxwidth 600 absolute
set style boxplot
set border back
dy=500 # zie y waarde terminal
# Hier worden de maximale en minimale y-waarden van gnuplot bepaald.
set terminal unknown
plot "<tail -24 ".file."" using :(-$5) w p, '' u :4 w p
ymax= GPVAL_Y_MAX
ymin= GPVAL_Y_MIN
ptmax=ymax*dy/(ymax-ymin)
ptmin=ymin*dy/(ymax-ymin)
replot
set terminal pngcairo truecolor enhanced size 1200, 500 font "Courier Bold,10" background rgb "#CFCFFF"
stats "<tail -24 ".file."" using 2:3 nooutput
afnt = STATS_sum_x
gelt = STATS_sum_y
afn = afnt/24
gel = gelt/24
stats "< tail -24 ".file."" using 4:5 nooutput
zon = STATS_max_x
zont = STATS_sum_x
geb = STATS_max_y
gebt = STATS_sum_y
zonavg = STATS_sum_x/24
gebavg = STATS_sum_y/24
stats "<tail -1 ".file."" using (strptime('%d-%m-%y %H:%M', stringcolumn(1))) nooutput
tijd = strftime('%H:%M', STATS_max)
set palette defined (-(geb) "#ee0000", 0 "#0000cc", 0 "#00aa00", (zon) "#ff0000")
unset colorbox
set title 'Alle energie-stromen van de laatste 24 uur.' font "Courier-Bold,12"
set xdata time
set timefmt '%d-%m-%y-%H:%M'
set xtics format "%H:%M" # dit is de opmaak zoals je hem gaat zien
set xtics 3600
set mxtics 0 # zet sub(minor)streepjes op de x-as
set grid ls 1 lw 1 lc rgb "#a0a0a0"
set autoscale xfix
set ytics font "Helvetica,8"
set mytics 2
set y2tics axis out 0
set ylabel "V e r m o g e n in Watt" offset 2,1
set object rect from screen 0.05, screen 0.04 to screen 0.08, screen 0.06 fc rgb '#00B900' front
set object rect from sc 0.05, sc 0.01 to sc 0.08, sc 0.03 fc rgb 'blue' front
set object rect from sc 0.25, sc 0.04 to sc 0.28, sc 0.06 fc rgb 'green'
set object 10 rect from sc 0.25, sc 0.01 to sc 0.28, sc 0.03 fc rgb "red" fs solid 1.0 front
set object 10 rect from sc 0.25, sc 0.01 to sc 0.28, sc 0.03 fc rgb "#5555ff" fs solid 1.0 front
# graph x, y
set label font "Courier Bold, 10" # grootte font tbv labels in het grafiek
set label 1 sprintf("Energiestromen gemiddeld per uur.") at screen 0.05,0.08 tc rgb "black" front
set label 2 sprintf("Zon = %4.0f W/h",zonavg) at screen 0.085,0.05 front
set label 3 sprintf("Gebruikt = %4.0f W/h",gebavg) at screen 0.085,0.025 front
set label 4 sprintf("Geleverd = %4.0f W/h",gel) at screen 0.285,0.05 front
set label 5 sprintf("Afgenomen = %4.0f W/h",afn) at screen 0.285,0.025 front
set label 6 sprintf("Energiestromen van de afgelopen 24 uur.") at screen 0.5,0.08 front
set label 7 sprintf("Gebruikt (%dW) = zon (%dW) - geleverd (%dW) + afgenomen (%dW)", gebt, zont, gelt, afnt) at screen 0.5,0.05 tc rgb "black" front
set label 11 sprintf("Logtijd: ") at screen 0.05,0.92 font "Courier-Bold,8" front
set label 12 sprintf(tijd) at screen 0.091,0.92 font "Courier-Bold,8" front
set style fill solid noborder# was transparent solid 0.5 border 0.5
n = 51
# n is het aantal kolommen wat wordt opgebouwd teneinde een gradient te krijgen. Hoe hoger "n" des te vloeiender de gradient
# De 1e serie is zon, de 2e serie is geleverd, de 3e serie is gebruik en de 4e serie is afgenomen.
# Het getal 12 is het aantal punten van één karakter Courier-Bold 10 hetgeen hier is gebruikt voor de labels.
plot for [i=n:0:-1] "<tail -24 ".file."" u ($1-600):(($4/n)*i):(($4/n)*i) w boxes lc palette notitle,\
"<tail -24 ".file."" u ($1-600):4:( $4>0 && ($4/ymax*ptmax)> (12 * strlen(sprintf("%d", $4))) ? $4 : sprintf("")) w labels right rotate font ",10" tc rgb "white" offset 0,-0.1 notitle,\
"<tail -24 ".file."" u ($1-600):4:( $4>0 && ($4/ymax*ptmax)<=(12 * strlen(sprintf("%d", $4))) ? $4 : sprintf("")) w labels left rotate font ",10" tc rgb "black" offset 0,0.1 notitle,\
"<tail -24 ".file."" u ($1-600):4 w boxes lc rgb "black" fill empty notitle,\
"<tail -24 ".file."" u ($1+600):3 w boxes lt 1 lc rgb "green" fillstyle solid notitle,\
"<tail -24 ".file."" u ($1+600):3 w boxes lc rgb "black" fill empty notitle,\
"<tail -24 ".file."" u ($1+600):3:( $3>0 && ($3/ymax*ptmax)> (12 * strlen(sprintf("%d", $3))) ? $3 : sprintf("")) w labels right rotate font ",10" tc rgb "blue" offset 0,-0.1 notitle,\
"<tail -24 ".file."" u ($1+600):3:( $3>0 && ($3/ymax*ptmax)<=(12 * strlen(sprintf("%d", $3))) ? $3 : sprintf("")) w labels left rotate font ",10" tc rgb "black" offset 0,0.1 notitle,\
for [i=n:0:-1] "<tail -24 ".file."" u ($1-600):((-($5)/n)*i):((-($5)/n)*i) w boxes lc palette notitle,\
"<tail -24 ".file."" u ($1-600):(-$5):( $5>0 && ($5/ymax*ptmax)> (12 * strlen(sprintf("%d", $5))) ? -$5 : sprintf("")) w labels left rotate font ",10" tc rgb "white" offset 0,0.1 notitle,\
"<tail -24 ".file."" u ($1-600):(-$5):( $5>0 && ($5/ymax*ptmax)<=(12 * strlen(sprintf("%d", $5))) ? -$5 : sprintf("")) w labels right rotate font ",10" tc rgb "black" offset 0,-0.1 notitle,\
"<tail -24 ".file."" u ($1-600):(-$5) w boxes lc rgb "black" fill empty notitle,\
"<tail -24 ".file."" u ($1+600):(-$2) w boxes lc rgb "#5555ff" fillstyle solid notitle,\
"<tail -24 ".file."" u ($1+600):(-$2) w boxes lc rgb "black" fill empty notitle,\
"<tail -24 ".file."" u ($1+600):(-$2):( $2>0 && ($2/ymax*ptmax)> (12 * strlen(sprintf("%d", $2))) ? -$2 : sprintf("")) w labels left rotate font ",10" tc rgb "white" offset 0,0.1 notitle,\
"<tail -24 ".file."" u ($1+600):(-$2):( $2>0 && ($2/ymax*ptmax)<=(12 * strlen(sprintf("%d", $2))) ? -$2 : sprintf("")) w labels right rotate font ",10" tc rgb "black" offset 0,-0.1 notitle
The complete datafile can you find here: http://ccvd.eu/downloads/uur.txt
There are two problems: First you must use the correct time format %d-%m-%Y-%H:%M in all cases (in the script you posted, you have a small y, and in the stats command you are missing a dash).
And, second, you must use timecolumn(1) instead of $1 in the using statement in order to have the date parsed correctly. When you had a timestamp, it worked fine since it was only a number, but parsing of the string failed. So your complete script should be
file = 'uur.txt'
set output "dag.png"
set datafile separator ","
set linestyle 1 lt 1 lc rgb "black"
set bmargin 5 # witruimte onder grafiek
set boxwidth 600 absolute
set style boxplot
set border back
dy=500 # zie y waarde terminal
# Hier worden de maximale en minimale y-waarden van gnuplot bepaald.
set terminal unknown
plot "<tail -24 ".file."" using :(-$5) w p, '' u :4 w p
ymax= GPVAL_Y_MAX
ymin= GPVAL_Y_MIN
ptmax=ymax*dy/(ymax-ymin)
ptmin=ymin*dy/(ymax-ymin)
replot
set terminal pngcairo truecolor enhanced size 1200, 500 font "Courier Bold,10" background rgb "#CFCFFF"
stats "<tail -24 ".file."" using 2:3 nooutput
afnt = STATS_sum_x
gelt = STATS_sum_y
afn = afnt/24
gel = gelt/24
stats "< tail -24 ".file."" using 4:5 nooutput
zon = STATS_max_x
zont = STATS_sum_x
geb = STATS_max_y
gebt = STATS_sum_y
zonavg = STATS_sum_x/24
gebavg = STATS_sum_y/24
stats "<tail -1 ".file."" using (strptime('%d-%m-%Y-%H:%M', stringcolumn(1))) nooutput
tijd = strftime('%H:%M', STATS_max)
set palette defined (-(geb) "#ee0000", 0 "#0000cc", 0 "#00aa00", (zon) "#ff0000")
unset colorbox
set title 'Alle energie-stromen van de laatste 24 uur.' font "Courier-Bold,12"
set xdata time
set timefmt '%d-%m-%Y-%H:%M'
set xtics format "%H:%M" # dit is de opmaak zoals je hem gaat zien
set xtics 3600
set mxtics 0 # zet sub(minor)streepjes op de x-as
set grid ls 1 lw 1 lc rgb "#a0a0a0"
set autoscale xfix
set ytics font "Helvetica,8"
set mytics 2
set y2tics axis out 0
set ylabel "V e r m o g e n in Watt" offset 2,1
set object rect from screen 0.05, screen 0.04 to screen 0.08, screen 0.06 fc rgb '#00B900' front
set object rect from sc 0.05, sc 0.01 to sc 0.08, sc 0.03 fc rgb 'blue' front
set object rect from sc 0.25, sc 0.04 to sc 0.28, sc 0.06 fc rgb 'green'
set object 10 rect from sc 0.25, sc 0.01 to sc 0.28, sc 0.03 fc rgb "red" fs solid 1.0 front
set object 10 rect from sc 0.25, sc 0.01 to sc 0.28, sc 0.03 fc rgb "#5555ff" fs solid 1.0 front
# graph x, y
set label font "Courier Bold, 10" # grootte font tbv labels in het grafiek
set label 1 sprintf("Energiestromen gemiddeld per uur.") at screen 0.05,0.08 tc rgb "black" front
set label 2 sprintf("Zon = %4.0f W/h",zonavg) at screen 0.085,0.05 front
set label 3 sprintf("Gebruikt = %4.0f W/h",gebavg) at screen 0.085,0.025 front
set label 4 sprintf("Geleverd = %4.0f W/h",gel) at screen 0.285,0.05 front
set label 5 sprintf("Afgenomen = %4.0f W/h",afn) at screen 0.285,0.025 front
set label 6 sprintf("Energiestromen van de afgelopen 24 uur.") at screen 0.5,0.08 front
set label 7 sprintf("Gebruikt (%dW) = zon (%dW) - geleverd (%dW) + afgenomen (%dW)", gebt, zont, gelt, afnt) at screen 0.5,0.05 tc rgb "black" front
set label 11 sprintf("Logtijd: ") at screen 0.05,0.92 font "Courier-Bold,8" front
set label 12 sprintf(tijd) at screen 0.091,0.92 font "Courier-Bold,8" front
set style fill solid noborder# was transparent solid 0.5 border 0.5
n = 51
# n is het aantal kolommen wat wordt opgebouwd teneinde een gradient te krijgen. Hoe hoger "n" des te vloeiender de gradient
# De 1e serie is zon, de 2e serie is geleverd, de 3e serie is gebruik en de 4e serie is afgenomen.
# Het getal 12 is het aantal punten van één karakter Courier-Bold 10 hetgeen hier is gebruikt voor de labels.
plot for [i=n:0:-1] "<tail -24 ".file."" u (timecolumn(1)-600):(($4/n)*i):(($4/n)*i) w boxes lc palette notitle,\
"<tail -24 ".file."" u (timecolumn(1)-600):4:( $4>0 && ($4/ymax*ptmax)> (12 * strlen(sprintf("%d", $4))) ? $4 : sprintf("")) w labels right rotate font ",10" tc rgb "white" offset 0,-0.1 notitle,\
"<tail -24 ".file."" u (timecolumn(1)-600):4:( $4>0 && ($4/ymax*ptmax)<=(12 * strlen(sprintf("%d", $4))) ? $4 : sprintf("")) w labels left rotate font ",10" tc rgb "black" offset 0,0.1 notitle,\
"<tail -24 ".file."" u (timecolumn(1)-600):4 w boxes lc rgb "black" fill empty notitle,\
"<tail -24 ".file."" u (timecolumn(1)+600):3 w boxes lt 1 lc rgb "green" fillstyle solid notitle,\
"<tail -24 ".file."" u (timecolumn(1)+600):3 w boxes lc rgb "black" fill empty notitle,\
"<tail -24 ".file."" u (timecolumn(1)+600):3:( $3>0 && ($3/ymax*ptmax)> (12 * strlen(sprintf("%d", $3))) ? $3 : sprintf("")) w labels right rotate font ",10" tc rgb "blue" offset 0,-0.1 notitle,\
"<tail -24 ".file."" u (timecolumn(1)+600):3:( $3>0 && ($3/ymax*ptmax)<=(12 * strlen(sprintf("%d", $3))) ? $3 : sprintf("")) w labels left rotate font ",10" tc rgb "black" offset 0,0.1 notitle,\
for [i=n:0:-1] "<tail -24 ".file."" u (timecolumn(1)-600):((-($5)/n)*i):((-($5)/n)*i) w boxes lc palette notitle,\
"<tail -24 ".file."" u (timecolumn(1)-600):(-$5):( $5>0 && ($5/ymax*ptmax)> (12 * strlen(sprintf("%d", $5))) ? -$5 : sprintf("")) w labels left rotate font ",10" tc rgb "white" offset 0,0.1 notitle,\
"<tail -24 ".file."" u (timecolumn(1)-600):(-$5):( $5>0 && ($5/ymax*ptmax)<=(12 * strlen(sprintf("%d", $5))) ? -$5 : sprintf("")) w labels right rotate font ",10" tc rgb "black" offset 0,-0.1 notitle,\
"<tail -24 ".file."" u (timecolumn(1)-600):(-$5) w boxes lc rgb "black" fill empty notitle,\
"<tail -24 ".file."" u (timecolumn(1)+600):(-$2) w boxes lc rgb "#5555ff" fillstyle solid notitle,\
"<tail -24 ".file."" u (timecolumn(1)+600):(-$2) w boxes lc rgb "black" fill empty notitle,\
"<tail -24 ".file."" u (timecolumn(1)+600):(-$2):( $2>0 && ($2/ymax*ptmax)> (12 * strlen(sprintf("%d", $2))) ? -$2 : sprintf("")) w labels left rotate font ",10" tc rgb "white" offset 0,0.1 notitle,\
"<tail -24 ".file."" u (timecolumn(1)+600):(-$2):( $2>0 && ($2/ymax*ptmax)<=(12 * strlen(sprintf("%d", $2))) ? -$2 : sprintf("")) w labels right rotate font ",10" tc rgb "black" offset 0,-0.1 notitle
with the expected output of

How to speed up matplotlib scatter ploting?

I need to draw a batch of scatter charts in matplotlib, and found the speed of matplotlib is slow, then I lineprofile the function, and found the hotspot is fig, ax = plt.subplots(), It costs 56.1% of time to creat a blank figure and axes !!
How to speed it up ? I mean, how can I reuse fig and ax to avoid creating them each time ?
Attach the profile report here (I cut some of the line to make it simple)
Total time: 0.733771 s
Line # Hits Time Per Hit % Time Line Contents
==============================================================
517 #profile
518 def df_scatter(df):
519 ''' draw the scatter plot for Pandas dataframe 'df'
533 '''
536
537 1 75 75.0 0.0 biggest_area = 1000
538 1 117 117.0 0.0 mycm = matplotlib.cm.get_cmap('jet') # 'spectral'
539
541 1 78 78.0 0.0 col_qty = len(df.columns)
543
544 1 1859 1859.0 0.1 x = list(df.ix[:,0].values)
545 1 1258 1258.0 0.0 y = list(df.ix[:,1].values)
551
552 1 1472345 1472345.0 56.1 fig, ax = plt.subplots()
556
557 1 7007 7007.0 0.3 plt.subplots_adjust(left=0.07, right=0.92, bottom=0.1, top=0.95)
558 1 179 179.0 0.0 x_margin, y_margin = (max(x)-min(x))/20, (max(y)-min(y))/20
563
564 1 71 71.0 0.0 if col_qty > 2:
565 1 1602 1602.0 0.1 r = list(df.ix[:,2].values)
566 1 309 309.0 0.0 size_r = np.array(biggest_area)*r/max(r)
585
586 1 34712 34712.0 1.3 sc = plt.scatter(x, y, marker='o', s=size_r, cmap=mycm, alpha=0.65)
587
588 # adding colorbar
589 1 542417 542417.0 20.7 cbaxes = fig.add_axes([0.94, 0.25, 0.02, 0.70])
590 1 165719 165719.0 6.3 cbar = plt.colorbar(sc, cax=cbaxes)
591 1 122 122.0 0.0 cbar.solids.set_edgecolor('face')
595
602 1 1061 1061.0 0.0 plt.figtext(0.94,0.10,"%0.1f"%(max(r)), fontproperties=TEXT_FONT_MEDIUM)
639 1 66 66.0 0.0 return fig
I think that the best way to do it is calling
fig = plt.figure()
ax=fig.add_subplot(111)
from outside of df_scatter. Then, pass it to df_scatter as arguments:
df_scatter(df,fig,ax):
or simply do inside df_scatter:
def df_scatter(df):
fig = plt.gcf()
ax = plt.gca()
after the creation of fig & axis was done.

Preview OSX bug (?) converting bezier curve in .eps file to .pdf

I have a small .eps file which uses bezier curves with a thick linewidth to achieve a certain effect. This file displays as I expect it to in gv, but when I convert it to a .pdf (eg with ps2pdf or by opening the file with Preview on a Mac running OSX) it renders some of the curves incorrectly (or at least, not in the way I was expecting); in the middle of the curve, the normals to the curve seem to "flip over", producing a strange artifact.
Here is the .eps file in question, as code:
%!PS-Adobe-2.0 EPSF-2.0
%%BoundingBox: 0 0 750 200
gsave 50 50 scale 1 3 translate
/edge{4 dict begin
/y2 exch def
/x2 exch def
/y1 exch def
/x1 exch def
gsave
1 setgray
1 8 div setlinewidth
newpath
x1 y1 moveto x2 y2 lineto
stroke
0 setgray
1 20 div setlinewidth
newpath
x1 y1 moveto x2 y2 lineto
stroke
x1 y1 0.07 0 360 arc fill stroke
x2 y2 0.07 0 360 arc fill stroke
grestore
end}def
/cur_edge{7 dict begin
/T exch def
/angle2 exch def
/y2 exch def
/x2 exch def
/angle1 exch def
/y1 exch def
/x1 exch def
gsave
1 setgray
1 8 div setlinewidth
newpath
x1 y1 moveto
x1 angle1 cos T mul add y1 angle1 sin T mul add
x2 angle2 cos T mul add y2 angle2 sin T mul add
x2 y2 curveto
stroke
0 setgray
1 20 div setlinewidth
newpath
x1 y1 moveto
x1 angle1 cos T mul add y1 angle1 sin T mul add
x2 angle2 cos T mul add y2 angle2 sin T mul add
x2 y2 curveto
stroke
x1 y1 0.07 0 360 arc fill stroke
x2 y2 0.07 0 360 arc fill stroke
grestore
end}def
/fat_edge{7 dict begin
/T exch def
/angle2 exch def
/y2 exch def
/x2 exch def
/angle1 exch def
/y1 exch def
/x1 exch def
gsave
0 setgray
1 4 div setlinewidth
newpath
x1 y1 moveto
x1 angle1 cos T mul add y1 angle1 sin T mul add
x2 angle2 cos T mul add y2 angle2 sin T mul add
x2 y2 curveto
stroke
0.9 setgray
1 5 div setlinewidth
newpath
x1 y1 moveto
x1 angle1 cos T mul add y1 angle1 sin T mul add
x2 angle2 cos T mul add y2 angle2 sin T mul add
x2 y2 curveto
stroke
grestore
end}def
/fat_vertex{4 dict begin
/angle exch def
/y exch def
/x exch def
/T 0.14 def
gsave
0.9 setgray
1 5.5 div setlinewidth
newpath
x y moveto
x angle cos T mul add y angle sin T mul add lineto
stroke
grestore
end}def
/extra_fat_vertex{5 dict begin
/y exch def
/x exch def
/w 0.16 def
gsave
1 setgray
newpath
x w sub y w sub moveto
x w add y w sub lineto
x w add y w add lineto
x w sub y w add lineto
closepath
fill
stroke
0 setgray
/v 0.12 def
newpath
x v sub y v sub moveto
x v add y v sub lineto
x v add y v add lineto
x v sub y v add lineto
closepath
fill
0.9 setgray
/u 0.095 def
newpath
x u sub y u sub moveto
x u add y u sub lineto
x u add y u add lineto
x u sub y u add lineto
closepath
fill
grestore
end}def
/extra_fat_triangle{5 dict begin
/y exch def
/x exch def
/w 0.16 def
gsave
1 setgray
newpath
x w sub y w sub moveto
x w 1.1 mul add y lineto
x w sub y w add lineto
closepath
fill
stroke
0 setgray
/v 0.12 def
newpath
x v sub y v sub moveto
x v add y lineto
x v sub y v add lineto
closepath
fill
0.9 setgray
/u 0.095 def
newpath
x u sub y u sub moveto
x u 0.85 mul add y lineto
x u sub y u add lineto
closepath
fill
grestore
end}def
/extra_fat_triangle_left{5 dict begin
/y exch def
/x exch def
/w 0.16 def
gsave
1 setgray
newpath
x w add y w sub moveto
x w 1.1 mul sub y lineto
x w add y w add lineto
closepath
fill
stroke
0 setgray
/v 0.12 def
newpath
x v add y v sub moveto
x v sub y lineto
x v add y v add lineto
closepath
fill
0.9 setgray
/u 0.095 def
newpath
x u add y u sub moveto
x u 0.85 mul sub y lineto
x u add y u add lineto
closepath
fill
grestore
end}def
0 0 90 2 0 270 1 cur_edge
% 0 0 270 2 0 90 1 cur_edge
2 0 90 0 0 270 1 cur_edge
0 0 180 0.5 -2 180 1 cur_edge
0.5 -2 90 1.5 -1.3 180 0.5 cur_edge
1.5 -1.3 270 2.5 -2 270 0.7 cur_edge
2.5 -2 90 0.5 -2 270 1 cur_edge %
2.5 -2 0 3 -0.75 0 1 cur_edge
3 -0.75 270 1.5 -1.3 0 0.7 cur_edge
3 -0.75 180 1.5 -1.3 90 0.7 cur_edge
3 -0.75 90 2 0 0 0.5 cur_edge
5 0 translate
0 0 90 2 0 270 1 fat_edge
% 0 0 270 2 0 90 1 fat_edge
2 0 90 0 0 270 1 fat_edge
0 0 180 0.5 -2 180 1 fat_edge
0.5 -2 90 1.5 -1.3 180 0.5 fat_edge
1.5 -1.3 270 2.5 -2 270 0.7 fat_edge
2.5 -2 90 0.5 -2 270 1 fat_edge
2.5 -2 0 3 -0.75 0 1 fat_edge
3 -0.75 270 1.5 -1.3 0 0.7 fat_edge
3 -0.75 180 1.5 -1.3 90 0.7 fat_edge
3 -0.75 90 2 0 0 0.5 fat_edge
0 0 90 fat_vertex
0 0 180 fat_vertex
0 0 270 fat_vertex
2 0 0 fat_vertex
2 0 90 fat_vertex
2 0 270 fat_vertex
0.5 -2 180 fat_vertex
0.5 -2 90 fat_vertex
2.5 -2 90 fat_vertex
2.5 -2 270 fat_vertex
1.5 -1.3 0 fat_vertex
1.5 -1.3 90 fat_vertex
1.5 -1.3 180 fat_vertex
1.5 -1.3 270 fat_vertex
3 -0.75 0 fat_vertex
3 -0.75 90 fat_vertex
3 -0.75 180 fat_vertex
3 -0.75 270 fat_vertex
5 0 translate
0 0 90 2 0 270 1 fat_edge
% 0 0 270 2 0 90 1 fat_edge
2 0 90 0 0 270 1 fat_edge
0 0 180 0.5 -2 180 1 fat_edge
0.5 -2 90 1.5 -1.3 180 0.5 fat_edge
1.5 -1.3 270 2.5 -2 270 0.7 fat_edge
2.5 -2 90 0.5 -2 270 1 fat_edge
2.5 -2 0 3 -0.75 0 1 fat_edge
3 -0.75 270 1.5 -1.3 0 0.7 fat_edge
3 -0.75 180 1.5 -1.3 90 0.7 fat_edge
3 -0.75 90 2 0 0 0.5 fat_edge
0 0 90 fat_vertex
0 0 180 fat_vertex
0 0 270 fat_vertex
2 0 0 fat_vertex
2 0 90 fat_vertex
2 0 270 fat_vertex
0.5 -2 180 fat_vertex
0.5 -2 90 fat_vertex
2.5 -2 90 fat_vertex
2.5 -2 270 fat_vertex
1.5 -1.3 0 fat_vertex
1.5 -1.3 90 fat_vertex
1.5 -1.3 180 fat_vertex
1.5 -1.3 270 fat_vertex
3 -0.75 0 fat_vertex
3 -0.75 90 fat_vertex
3 -0.75 180 fat_vertex
3 -0.75 270 fat_vertex
0 0 extra_fat_triangle
2 0 extra_fat_triangle_left
0.5 -2 extra_fat_triangle
1.5 -1.3 extra_fat_vertex
2.5 -2 extra_fat_triangle_left
3 -0.75 extra_fat_vertex
grestore
%eof
What is curious is that the .pdf only displays incorrectly when it is resized to certain specific sizes (or: it displays correctly at certain sizes). I don't seem to be able to predict when it will work.
Here is how it displays (part of the image) correctly:
And here it is resized and displaying incorrectly:
(source: dannyc at math.uchicago.edu)
Note that these images are .jpgs obtained from the .pdf. If you save the code above as an .eps file and open it with Preview on a Mac, I assume it will exhibit the same pathology it did on my computer.
Any advice would be very welcome. I don't know enough (or: anything) about how bezier curves are displayed in .pdf to know what might be the problem here.
Here's a cut down case that displays the same rendering problem:
%!PS-Adobe-2.0 EPSF-2.0
%%BoundingBox: 0 0 400 200
gsave 50 50 scale 1 3 translate
0 setgray
0.05 setlinewidth
newpath
0 0 moveto
0 1 2 -1 2 0 curveto
stroke
grestore
%eof
Can't get much simpler than that: a Bezier path with just two points, all with integer values.
It looks like Apple's renderer has some numeric instability around the center of the curve. If you tweak one of the curve control points by a tiny amount, the bug doesn't happen:
0 1.00001 2 -1 2 0 curveto
So there's a workaround: In your original file, add a small fudge factor (a fraction of a degree) to one of the angles in each curve.
I changed each /angle1 exch def to 0.01 add /angle1 exch def, and it worked for me. Here's the EPS file and the resulting PDF file.
(Of course this shouldn't be necessary, but until you file a bug and Apple releases a fix, it may be the most expedient solution.)

Resources