firstly, I'm very new to GNUPlot, so please forgive me if I might sound silly or say stupid things.
I have to visualise some 3D data. I firstly wanted to have something that just worked correctly.
Here it is an example:
It's a scatter plot, meaning that I have the list of all (x, y, z) values, which come from a given computation.
I was now wondering if there is a way to convert this plot into a surf-like one, but without having to create a grid-mesh, because actually, real plots are made up of many of these zones, contingent in space, but not necessarily in memory (i.e. there's not order in listing all points, as well as each patch has its own setup). In which case, creating a grid is not possible..
Here is the script I built up to now:
# Main window settings
MAINFONT = ""
WINDOWTITLE = "BRM (mesher)"
WSIZEW = 3040 # base: 1980
WSIZEH = 2080 # base: 1080
set term wxt \
size WSIZEW, WSIZEH \
position 50, 50 \
font MAINFONT title WINDOWTITLE
#
# commands taken from GNU demo folder
#
# unset hidden3d
# set parametric
set view 45, 45
set border linestyle 102 linewidth 2
# draws a grid in the XY plane (at the base)
# set style line 102 lc rgb "#d6d7d9" lt 0 lw 1
set grid back ls 102
#
# setting styles
#
LINETYP = 8
LINEWDT = 2
POINTTY = 7
POINTIN = 0
POINTSZ = 1
# "#AARRGGBB"
set style line 1 linecolor rgb "#B5000000" \
linetype LINETYP linewidth LINEWDT \
pointtype POINTTY pointinterval POINTIN pointsize POINTSZ
set style line 2 linecolor rgb "#B5EEEEEE" \
linetype LINETYP linewidth LINEWDT \
pointtype POINTTY pointinterval POINTIN pointsize POINTSZ
set style data points
# #
# # LEGEND (related)
# #
# LEGENDTITLE = "brm"
# set key nobox \
# title LEGENDTITLE
#
# Annotation: title and labels
#
FIGURETITLE = "Bispectrum (MESHER)"
XLABEL = "f_1"
YLABEL = "f_2"
set title FIGURETITLE
set xlabel XLABEL
set ylabel YLABEL
# ??
set ticslevel 0.1
#
# RANGES
#
_xrange = 0
_yrange = 0
_xrangev_min = -0.58
_xrangev_max = 0.58
if (_xrange == 0) \
set autoscale x; \
else \
set xrange [_xrangev_min : _xrangev_max]
_yrangev_min = -0.58
_yrangev_max = 0.58
if (_yrange == 0) \
set autoscale y; \
else \
set yrange [_yrangev_min : _yrangev_max]
# by default, always autoscale Z axis
set autoscale z
#
# PALETTE (???)
#
set palette defined
#
# DATA file - ACTUAL PLOTTING (end of script)
#
DATAFILE = "brm_gnu.dat"
splot DATAFILE linestyle 1
set terminal png transparent \
size WSIZEW, WSIZEH \
truecolor enhanced
set out 'brm_gnu.png'
splot DATAFILE linestyle 2
Data in file brm_gnu.dat is layed down like this:
-0.925000000000000 -0.925000000000000 -1.112830727291687E-010
-0.925000000000000 -0.906500000000000 -1.233145093750881E-010
-0.925000000000000 -0.888000000000000 -1.366284414075596E-010
-0.925000000000000 -0.869500000000000 -1.519484378717266E-010
-0.925000000000000 -0.851000000000000 -1.689727146344101E-010
-0.925000000000000 -0.832500000000000 -1.886477866098199E-010
-0.925000000000000 -0.814000000000000 -2.106127410033206E-010
-0.925000000000000 -0.795500000000000 -2.361154837990765E-010
-0.925000000000000 -0.777000000000000 -2.647322799551845E-010
-0.925000000000000 -0.758500000000000 -2.981225082072651E-010
-0.925000000000000 -0.740000000000000 -3.358043924792572E-010
-0.925000000000000 -0.721500000000000 -3.800054710485629E-010
-0.925000000000000 -0.703000000000000 -4.302096737531581E-010
-0.925000000000000 -0.684500000000000 -4.894396712358350E-010
-0.925000000000000 -0.666000000000000 -5.572088806295344E-010
-0.925000000000000 -0.647500000000001 -6.376713565360164E-010
-0.925000000000000 -0.629000000000001 -7.305164855939753E-010
-0.925000000000000 -0.610500000000001 -8.415428103502650E-010
-0.925000000000000 -0.592000000000001 -9.709330437110598E-010
-0.925000000000000 -0.573500000000001 -1.126945044480171E-009
-0.925000000000000 -0.555000000000001 -1.310931309425567E-009
-0.925000000000000 -0.536500000000001 -1.534975141884201E-009
-0.925000000000000 -0.518000000000001 -1.803055173016286E-009
-0.925000000000000 -0.499500000000001 -2.133544704946095E-009
-0.925000000000000 -0.481000000000001 -2.536285945770245E-009
-0.925000000000000 -0.462500000000001 -3.040837628811161E-009
-0.925000000000000 -0.444000000000001 -3.670506613697746E-009
-0.925000000000000 -0.425500000000001 -4.477002392036607E-009
-0.925000000000000 -0.407000000000001 -5.516399793216453E-009
-0.925000000000000 -0.388500000000001 -6.890678221135726E-009
-0.925000000000000 -0.370000000000001 -8.742275516296416E-009
-0.925000000000000 -0.351500000000001 -1.130228554007822E-008
-0.925000000000000 -0.333000000000001 -1.493876996861222E-008
-0.925000000000000 -0.314500000000001 -2.008105455788527E-008
-0.925000000000000 -0.296000000000001 -2.639740388136111E-008
-0.925000000000000 -0.277500000000001 -2.495551205522123E-008
-0.925000000000000 -0.259000000000001 1.217373182500029E-008
-0.925000000000000 -0.240500000000001 4.002042521882181E-008
-0.925000000000000 -0.222000000000001 3.920606423887810E-008
-0.925000000000000 -0.203500000000001 3.394892837099711E-008
-0.925000000000000 -0.185000000000001 2.982629548434422E-008
-0.925000000000000 -0.166500000000001 2.650822114502139E-008
-0.925000000000000 -0.148000000000001 2.419113779933117E-008
-0.925000000000000 -0.129500000000001 2.199076752962076E-008
-0.925000000000000 -0.111000000000001 2.033869550352628E-008
-0.925000000000000 -9.250000000000064E-002 1.831654441535893E-008
-0.925000000000000 -7.400000000000063E-002 1.660422884667210E-008
-0.925000000000000 -5.550000000000063E-002 1.405821421353012E-008
-0.925000000000000 -3.700000000000063E-002 1.162135856322721E-008
-0.925000000000000 -1.850000000000063E-002 7.711497131970931E-009
-0.925000000000000 -6.314393452555578E-016 3.612797228830624E-009
-0.925000000000000 1.849999999999937E-002 9.044608397276898E-009
-0.925000000000000 3.699999999999937E-002 1.517231304642434E-008
-0.925000000000000 5.549999999999937E-002 2.100479548010471E-008
-0.925000000000000 7.399999999999937E-002 2.794273124567097E-008
-0.925000000000000 9.249999999999937E-002 3.515439985695759E-008
-0.925000000000000 0.110999999999999 4.417517701787027E-008
-0.925000000000000 0.129499999999999 5.446047844096278E-008
-0.925000000000000 0.147999999999999 6.804953706846881E-008
-0.925000000000000 0.166499999999999 8.514167966829595E-008
-0.925000000000000 0.184999999999999 1.092469464956259E-007
-0.925000000000000 0.203499999999999 1.424166963507360E-007
-0.925000000000000 0.221999999999999 1.886672091873319E-007
-0.925000000000000 0.240499999999999 2.226918466600739E-007
-0.925000000000000 0.258999999999999 8.361467589272240E-008
-0.925000000000000 0.277499999999999 -1.744810743977760E-007
-0.925000000000000 0.295999999999999 -2.169414767863524E-007
-0.925000000000000 0.314499999999999 -1.918417016294112E-007
-0.925000000000000 0.332999999999999 -1.660457713844593E-007
-0.925000000000000 0.351499999999999 -1.463673267513782E-007
-0.925000000000000 0.369999999999999 -1.324561338505409E-007
-0.925000000000000 0.388499999999999 -1.224425506157808E-007
-0.925000000000000 0.406999999999999 -1.156187000982741E-007
-0.925000000000000 0.425499999999999 -1.110329121612473E-007
-0.925000000000000 0.443999999999999 -1.085133392168845E-007
-0.925000000000000 0.462499999999999 -1.076295481079459E-007
-0.925000000000000 0.480999999999999 -1.085133392168845E-007
-0.925000000000000 0.499499999999999 -1.110329121612472E-007
-0.925000000000000 0.517999999999999 -1.156187000982739E-007
-0.925000000000000 0.536499999999999 -1.224425506157803E-007
-0.925000000000000 0.554999999999999 -1.324561338505402E-007
-0.925000000000000 0.573499999999999 -1.463673267513768E-007
-0.925000000000000 0.591999999999999 -1.660457713844573E-007
-0.925000000000000 0.610499999999999 -1.918417016294087E-007
-0.925000000000000 0.628999999999999 -2.169414767863508E-007
-0.925000000000000 0.647499999999999 -1.744810743977867E-007
-0.925000000000000 0.665999999999999 8.361467589269764E-008
-0.925000000000000 0.684499999999999 2.226918466600726E-007
-0.925000000000000 0.702999999999999 1.886672091873358E-007
-0.925000000000000 0.721499999999999 1.424166963507389E-007
-0.925000000000000 0.739999999999999 1.092469464956279E-007
-0.925000000000000 0.758499999999999 8.514167966829721E-008
-0.925000000000000 0.776999999999999 6.804953706846961E-008
-0.925000000000000 0.795499999999999 5.446047844096326E-008
-0.925000000000000 0.813999999999999 4.417517701787055E-008
-0.925000000000000 0.832499999999999 3.515439985695774E-008
-0.925000000000000 0.850999999999999 2.794273124567102E-008
-0.925000000000000 0.869499999999999 2.100479548010464E-008
-0.925000000000000 0.887999999999999 1.517231304642419E-008
-0.925000000000000 0.906499999999999 9.044608397276874E-009
-0.925000000000000 0.924999999999999 3.612797228830709E-009
-0.888000000000000 -0.925000000000000 -1.366284414075596E-010
-0.888000000000000 -0.906500000000000 -1.514554825885140E-010
-0.888000000000000 -0.888000000000000 -1.678715585166733E-010
-0.888000000000000 -0.869500000000000 -1.867669141753174E-010
-0.888000000000000 -0.851000000000000 -2.077756527881272E-010
-0.888000000000000 -0.832500000000000 -2.320637715170312E-010
-0.888000000000000 -0.814000000000000 -2.591939133899776E-010
-0.888000000000000 -0.795500000000000 -2.907054359991271E-010
-0.888000000000000 -0.777000000000000 -3.260854042965641E-010
-0.888000000000000 -0.758500000000000 -3.673837700039050E-010
-0.888000000000000 -0.740000000000000 -4.140185705201067E-010
-0.888000000000000 -0.721500000000000 -4.687460835720848E-010
-0.888000000000000 -0.703000000000000 -5.309456540028089E-010
-0.888000000000000 -0.684500000000000 -6.043640295947556E-010
-0.888000000000000 -0.666000000000000 -6.884223308909101E-010
-0.888000000000000 -0.647500000000001 -7.882796678741693E-010
-0.888000000000000 -0.629000000000001 -9.035829327128297E-010
-0.888000000000000 -0.610500000000001 -1.041548837634559E-009
-0.888000000000000 -0.592000000000001 -1.202448012416946E-009
-0.888000000000000 -0.573500000000001 -1.396581641103813E-009
-0.888000000000000 -0.555000000000001 -1.625692034292117E-009
-0.888000000000000 -0.536500000000001 -1.904889699074367E-009
-0.888000000000000 -0.518000000000001 -2.239214737295571E-009
-0.888000000000000 -0.499500000000001 -2.651702965951379E-009
-0.888000000000000 -0.481000000000001 -3.154754671938524E-009
-0.888000000000000 -0.462500000000001 -3.785524790771094E-009
-0.888000000000000 -0.444000000000001 -4.573321099493714E-009
-0.888000000000000 -0.425500000000001 -5.583291834596760E-009
-0.888000000000000 -0.407000000000001 -6.885924678859094E-009
-0.888000000000000 -0.388500000000001 -8.609926607920218E-009
-0.888000000000000 -0.370000000000001 -1.093443224260467E-008
-0.888000000000000 -0.351500000000001 -1.415141660472406E-008
-0.888000000000000 -0.333000000000001 -1.872420023868949E-008
-0.888000000000000 -0.314500000000001 -2.519643739342348E-008
-0.888000000000000 -0.296000000000001 -3.315091047770025E-008
-0.888000000000000 -0.277500000000001 -3.133806906065347E-008
-0.888000000000000 -0.259000000000001 1.546718386380113E-008
-0.888000000000000 -0.240500000000001 5.061374436033968E-008
-0.888000000000000 -0.222000000000001 4.962933230441113E-008
-0.888000000000000 -0.203500000000001 4.303993129303609E-008
-0.888000000000000 -0.185000000000001 3.787728624524228E-008
-0.888000000000000 -0.166500000000001 3.373039604908384E-008
-0.888000000000000 -0.148000000000001 3.084627797750065E-008
-0.888000000000000 -0.129500000000001 2.810937227742075E-008
-0.888000000000000 -0.111000000000001 2.606548441463560E-008
-0.888000000000000 -9.250000000000064E-002 2.354964918053996E-008
-0.888000000000000 -7.400000000000063E-002 2.142508131358988E-008
-0.888000000000000 -5.550000000000063E-002 1.823209774441858E-008
-0.888000000000000 -3.700000000000063E-002 1.517231304642424E-008
-0.888000000000000 -1.850000000000063E-002 1.021290092645047E-008
-0.888000000000000 -6.314393452555578E-016 4.996516315440040E-009
-0.888000000000000 1.849999999999937E-002 1.204686441977831E-008
-0.888000000000000 3.699999999999937E-002 2.003725247337349E-008
-0.888000000000000 5.549999999999937E-002 2.770656912576066E-008
-0.888000000000000 7.399999999999937E-002 3.686853319008584E-008
-0.888000000000000 9.249999999999937E-002 4.647057591600724E-008
-0.888000000000000 0.110999999999999 5.852674022159808E-008
-0.888000000000000 0.129499999999999 7.237217172770839E-008
-0.888000000000000 0.147999999999999 9.072779247103859E-008
-0.888000000000000 0.166499999999999 1.139536289449970E-007
-0.888000000000000 0.184999999999999 1.468272034445875E-007
-0.888000000000000 0.203499999999999 1.923234269198452E-007
-0.888000000000000 0.221999999999999 2.561821950532344E-007
-0.888000000000000 0.240499999999999 3.045967590943703E-007
-0.888000000000000 0.258999999999999 1.171993595810555E-007
-0.888000000000000 0.277499999999999 -2.378521699660832E-007
-0.888000000000000 0.295999999999999 -2.991990241636433E-007
-0.888000000000000 0.314499999999999 -2.667602282068009E-007
-0.888000000000000 0.332999999999999 -2.327707439729019E-007
-0.888000000000000 0.351499999999999 -2.069250337782313E-007
-0.888000000000000 0.369999999999999 -1.889997417787384E-007
-0.888000000000000 0.388499999999999 -1.764722762883600E-007
-0.888000000000000 0.406999999999999 -1.685374934037391E-007
-0.888000000000000 0.425499999999999 -1.638989791992446E-007
-0.888000000000000 0.443999999999999 -1.625314556369960E-007
-0.888000000000000 0.462499999999999 -1.638989791992444E-007
-0.888000000000000 0.480999999999999 -1.685374934037387E-007
-0.888000000000000 0.499499999999999 -1.764722762883594E-007
-0.888000000000000 0.517999999999999 -1.889997417787376E-007
-0.888000000000000 0.536499999999999 -2.069250337782301E-007
-0.888000000000000 0.554999999999999 -2.327707439728999E-007
-0.888000000000000 0.573499999999999 -2.667602282067980E-007
-0.888000000000000 0.591999999999999 -2.991990241636416E-007
-0.888000000000000 0.610499999999999 -2.378521699660962E-007
-0.888000000000000 0.628999999999999 1.171993595810264E-007
-0.888000000000000 0.647499999999999 3.045967590943685E-007
-0.888000000000000 0.665999999999999 2.561821950532387E-007
-0.888000000000000 0.684499999999999 1.923234269198487E-007
-0.888000000000000 0.702999999999999 1.468272034445898E-007
-0.888000000000000 0.721499999999999 1.139536289449986E-007
-0.888000000000000 0.739999999999999 9.072779247103978E-008
-0.888000000000000 0.758499999999999 7.237217172770904E-008
-0.888000000000000 0.776999999999999 5.852674022159847E-008
-0.888000000000000 0.795499999999999 4.647057591600741E-008
-0.888000000000000 0.813999999999999 3.686853319008582E-008
-0.888000000000000 0.832499999999999 2.770656912576058E-008
-0.888000000000000 0.850999999999999 2.003725247337335E-008
-0.888000000000000 0.869499999999999 1.204686441977828E-008
-0.888000000000000 0.887999999999999 4.996516315440152E-009
-0.888000000000000 0.906499999999999 1.021290092645066E-008
-0.888000000000000 0.924999999999999 1.517231304642449E-008
-0.906500000000000 -0.925000000000000 -1.233145093750881E-010
-0.906500000000000 -0.906500000000000 -1.366712162455961E-010
-0.906500000000000 -0.888000000000000 -1.514554825885140E-010
-0.906500000000000 -0.869500000000000 -1.684698988679970E-010
-0.906500000000000 -0.851000000000000 -1.873821383985311E-010
-0.906500000000000 -0.832500000000000 -2.092427346051062E-010
-0.906500000000000 -0.814000000000000 -2.336543459977473E-010
-0.906500000000000 -0.795500000000000 -2.620029506471153E-010
-0.906500000000000 -0.777000000000000 -2.938222817540006E-010
-0.906500000000000 -0.758500000000000 -3.309566693801141E-010
-0.906500000000000 -0.740000000000000 -3.728765161227582E-010
-0.906500000000000 -0.721500000000000 -4.220596246022149E-010
-0.906500000000000 -0.703000000000000 -4.779398944083059E-010
-0.906500000000000 -0.684500000000000 -5.438825499738923E-010
-0.906500000000000 -0.666000000000000 -6.193566049239658E-010
-0.906500000000000 -0.647500000000001 -7.089913437241107E-010
-0.906500000000000 -0.629000000000001 -8.124550216954241E-010
-0.906500000000000 -0.610500000000001 -9.362163645406903E-010
-0.906500000000000 -0.592000000000001 -1.080498172760888E-009
-0.906500000000000 -0.573500000000001 -1.254523323649140E-009
-0.906500000000000 -0.555000000000001 -1.459826376314463E-009
-0.906500000000000 -0.536500000000001 -1.709919380579901E-009
-0.906500000000000 -0.518000000000001 -2.009279152148843E-009
-0.906500000000000 -0.499500000000001 -2.378478052394948E-009
-0.906500000000000 -0.481000000000001 -2.828561117094100E-009
-0.906500000000000 -0.462500000000001 -3.392667355731829E-009
-0.906500000000000 -0.444000000000001 -4.096927601250477E-009
-0.906500000000000 -0.425500000000001 -4.999381363828435E-009
-0.906500000000000 -0.407000000000001 -6.162888260319948E-009
-0.906500000000000 -0.388500000000001 -7.702010777696916E-009
-0.906500000000000 -0.370000000000001 -9.776462968777032E-009
-0.906500000000000 -0.351500000000001 -1.264599184476242E-008
-0.906500000000000 -0.333000000000001 -1.672350388985956E-008
-0.906500000000000 -0.314500000000001 -2.249212029278521E-008
-0.906500000000000 -0.296000000000001 -2.957989097539718E-008
-0.906500000000000 -0.277500000000001 -2.796384756075452E-008
-0.906500000000000 -0.259000000000001 1.371887680503458E-008
-0.906500000000000 -0.240500000000001 4.500053541945885E-008
-0.906500000000000 -0.222000000000001 4.410536409817017E-008
-0.906500000000000 -0.203500000000001 3.822038841662931E-008
-0.906500000000000 -0.185000000000001 3.360739075021546E-008
-0.906500000000000 -0.166500000000001 2.989833461734862E-008
-0.906500000000000 -0.148000000000001 2.731337564207566E-008
-0.906500000000000 -0.129500000000001 2.485956140414542E-008
-0.906500000000000 -0.111000000000001 2.302206300210600E-008
-0.906500000000000 -9.250000000000064E-002 2.076683042691665E-008
-0.906500000000000 -7.400000000000063E-002 1.885973769795809E-008
-0.906500000000000 -5.550000000000063E-002 1.600921909170784E-008
-0.906500000000000 -3.700000000000063E-002 1.327938872744156E-008
-0.906500000000000 -1.850000000000063E-002 8.877473815630514E-009
-0.906500000000000 -6.314393452555578E-016 4.255507953928457E-009
-0.906500000000000 1.849999999999937E-002 1.044166431933323E-008
-0.906500000000000 3.699999999999937E-002 1.743614564704666E-008
-0.906500000000000 5.549999999999937E-002 2.412148830393200E-008
-0.906500000000000 7.399999999999937E-002 3.209052259334402E-008
-0.906500000000000 9.249999999999937E-002 4.040794806557133E-008
-0.906500000000000 0.110999999999999 5.083090912922838E-008
-0.906500000000000 0.129499999999999 6.275741062996620E-008
-0.906500000000000 0.147999999999999 7.854088457460013E-008
-0.906500000000000 0.166499999999999 9.845150853016995E-008
-0.906500000000000 0.184999999999999 1.265800089781315E-007
-0.906500000000000 0.203499999999999 1.653939929314344E-007
-0.906500000000000 0.221999999999999 2.196862110699713E-007
-0.906500000000000 0.240499999999999 2.602144086867102E-007
-0.906500000000000 0.258999999999999 9.884958131045721E-008
-0.906500000000000 0.277499999999999 -2.035802542405856E-007
-0.906500000000000 0.295999999999999 -2.545269003492000E-007
-0.906500000000000 0.314499999999999 -2.259593091092582E-007
-0.906500000000000 0.332999999999999 -1.963318006679911E-007
-0.906500000000000 0.351499999999999 -1.737574136603818E-007
-0.906500000000000 0.369999999999999 -1.579312255221945E-007
-0.906500000000000 0.388499999999999 -1.466792948328887E-007
-0.906500000000000 0.406999999999999 -1.392395360328343E-007
-0.906500000000000 0.425499999999999 -1.344964799883919E-007
-0.906500000000000 0.443999999999999 -1.323297848028745E-007
-0.906500000000000 0.462499999999999 -1.322469414183294E-007
-0.906500000000000 0.480999999999999 -1.345321624991211E-007
-0.906500000000000 0.499499999999999 -1.390900220084392E-007
-0.906500000000000 0.517999999999999 -1.466735981468943E-007
-0.906500000000000 0.536499999999999 -1.576717543811861E-007
-0.906500000000000 0.554999999999999 -1.737028723144627E-007
-0.906500000000000 0.573499999999999 -1.958655577255762E-007
-0.906500000000000 0.591999999999999 -2.258266556659192E-007
-0.906500000000000 0.610499999999999 -2.536813208860895E-007
-0.906500000000000 0.628999999999999 -2.033996127677433E-007
-0.906500000000000 0.647499999999999 9.839891803808796E-008
-0.906500000000000 0.665999999999999 2.598892689170532E-007
-0.906500000000000 0.684499999999999 2.183239868389179E-007
-0.906500000000000 0.702999999999999 1.651091175348573E-007
-0.906500000000000 0.721499999999999 1.255105409220265E-007
-0.906500000000000 0.739999999999999 9.821654436346623E-008
-0.906500000000000 0.758499999999999 7.762178553728138E-008
-0.906500000000000 0.776999999999999 6.254401541217292E-008
-0.906500000000000 0.795499999999999 4.997354948465678E-008
-0.906500000000000 0.813999999999999 4.020011324238698E-008
-0.906500000000000 0.832499999999999 3.124110268472883E-008
-0.906500000000000 0.850999999999999 2.390820741791080E-008
-0.906500000000000 0.869499999999999 1.655039280302377E-008
-0.906500000000000 0.887999999999999 1.021290092645050E-008
-0.906500000000000 0.906499999999999 9.561331090630669E-009
-0.906500000000000 0.924999999999999 9.044608397277014E-009
Thanks :)
PS: ANY suggestion/comment/critics not strictly related to the question, but that would improve my knowledge, is well accepted!
EDIT 1:
Here is an example of how I'd like the plot to look like instead:
You don't show nearly enough data to get a feel for what the full data set looks like. In the hope that it helps, here is an example of using set dgrid3d on a small number of points to produce a plot sort of like the one you show:
$DATA << EOD
-5.0 -5.0 0
-5.0 5.0 0
5.0 5.0 0
5.0 -5.0 0
0.0 0.0 0
-3.0 -2.0 8.e10
-1.0 2.0 6.e10
-2.0 -1.0 9.e10
2.0 2.0 5.e10
0.0 -3.0 8.e10
3.0 0.0 7.e10
EOD
set grid x y z
set grid vertical
set xyplane at 0
set dgrid3d 100,100 gauss kdensity 0.6, 0.6
splot $DATA with pm3d
Examples using amended data
Probably the best answer is to change your data format slightly so that each X value has its own block in the file. I.e. put a blank line between the section with X=-0.925 and the section with X=-0.888 and so on. That make the plot command very simple. However it seems there are some glitches in your data, maybe due to inconsistent sampling?
set hidden3d offset 0 # remove hidden lines
splot "DATA" with lines title "blank line between x slices"
A different way is to use dgrid3d as shown before. You must tailor the dgrid3d parameters and weighting scheme to your data. I cannot do that for you, you have to think about how you want each data point to contribute to the surface: How big is the neighborhood it affects? Is it a requirement that the surface pass exactly through each point? How smooth should the surface be? Etc...
Anyhow, here is a simple example using your amended data. The sample data pretty much consists of 100 samples for each x and 3 for each y so that's what we set as a grid. We ask for a spline fit through the points.
set dgrid3d 100,3 spline
set hidden3d
plot "DATA" with lines
Related
I have a layer in GeoServer which opens when default style like "polygon" is selected in the publishing menu
Layer opening with default style
but when I change its style in WMS Settings, for which I have created a new style by importing the SLD of same dateset from QGIS,
it shows the error like,
ERROR: invalid input syntax for type double precision
and the layer does not open.
error with new SLD
However while Validating the imported SLD, no errors were encountered.
validation of New SLD
The SLD used is as follows:
<StyledLayerDescriptor xmlns="http://www.opengis.net/sld" xmlns:se="http://www.opengis.net/se" xmlns:ogc="http://www.opengis.net/ogc" xsi:schemaLocation="http://www.opengis.net/sld http://schemas.opengis.net/sld/1.1.0/StyledLayerDescriptor.xsd" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<NamedLayer>
<se:Name>rainfall_forecast</se:Name>
<UserStyle>
<se:Name>rainfall_forecast</se:Name>
<se:FeatureTypeStyle>
<se:Rule>
<se:Name>0 - 10</se:Name>
<se:Description>
<se:Title>0 - 10</se:Title>
</se:Description>
<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
<ogc:Or>
<ogc:PropertyIsEqualTo>
<ogc:PropertyName>rainfall</ogc:PropertyName>
<ogc:Literal></ogc:Literal>
</ogc:PropertyIsEqualTo>
<ogc:PropertyIsNull>
<ogc:PropertyName>rainfall</ogc:PropertyName>
</ogc:PropertyIsNull>
</ogc:Or>
</ogc:Filter>
<se:PolygonSymbolizer>
<se:Fill>
<se:SvgParameter name="fill">#440154</se:SvgParameter>
</se:Fill>
<se:Stroke>
<se:SvgParameter name="stroke">#232323</se:SvgParameter>
<se:SvgParameter name="stroke-width">1</se:SvgParameter>
<se:SvgParameter name="stroke-linejoin">bevel</se:SvgParameter>
</se:Stroke>
</se:PolygonSymbolizer>
</se:Rule>
<se:Rule>
<se:Name>11 - 20</se:Name>
<se:Description>
<se:Title>11 - 20</se:Title>
</se:Description>
<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
<ogc:Or>
<ogc:PropertyIsEqualTo>
<ogc:PropertyName>rainfall</ogc:PropertyName>
<ogc:Literal></ogc:Literal>
</ogc:PropertyIsEqualTo>
<ogc:PropertyIsNull>
<ogc:PropertyName>rainfall</ogc:PropertyName>
</ogc:PropertyIsNull>
</ogc:Or>
</ogc:Filter>
<se:PolygonSymbolizer>
<se:Fill>
<se:SvgParameter name="fill">#24868e</se:SvgParameter>
</se:Fill>
<se:Stroke>
<se:SvgParameter name="stroke">#232323</se:SvgParameter>
<se:SvgParameter name="stroke-width">1</se:SvgParameter>
<se:SvgParameter name="stroke-linejoin">bevel</se:SvgParameter>
</se:Stroke>
</se:PolygonSymbolizer>
</se:Rule>
<se:Rule>
<se:Name>21 - 30</se:Name>
<se:Description>
<se:Title>21 - 30</se:Title>
</se:Description>
<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
<ogc:Or>
<ogc:PropertyIsEqualTo>
<ogc:PropertyName>rainfall</ogc:PropertyName>
<ogc:Literal></ogc:Literal>
</ogc:PropertyIsEqualTo>
<ogc:PropertyIsNull>
<ogc:PropertyName>rainfall</ogc:PropertyName>
</ogc:PropertyIsNull>
</ogc:Or>
</ogc:Filter>
<se:PolygonSymbolizer>
<se:Fill>
<se:SvgParameter name="fill">#5dc962</se:SvgParameter>
</se:Fill>
<se:Stroke>
<se:SvgParameter name="stroke">#232323</se:SvgParameter>
<se:SvgParameter name="stroke-width">1</se:SvgParameter>
<se:SvgParameter name="stroke-linejoin">bevel</se:SvgParameter>
</se:Stroke>
</se:PolygonSymbolizer>
</se:Rule>
<se:Rule>
<se:Name>31 - 40</se:Name>
<se:Description>
<se:Title>31 - 40</se:Title>
</se:Description>
<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
<ogc:Or>
<ogc:PropertyIsEqualTo>
<ogc:PropertyName>rainfall</ogc:PropertyName>
<ogc:Literal></ogc:Literal>
</ogc:PropertyIsEqualTo>
<ogc:PropertyIsNull>
<ogc:PropertyName>rainfall</ogc:PropertyName>
</ogc:PropertyIsNull>
</ogc:Or>
</ogc:Filter>
<se:PolygonSymbolizer>
<se:Fill>
<se:SvgParameter name="fill">#8fd744</se:SvgParameter>
</se:Fill>
<se:Stroke>
<se:SvgParameter name="stroke">#232323</se:SvgParameter>
<se:SvgParameter name="stroke-width">1</se:SvgParameter>
<se:SvgParameter name="stroke-linejoin">bevel</se:SvgParameter>
</se:Stroke>
</se:PolygonSymbolizer>
</se:Rule>
<se:Rule>
<se:Name>41 - 50</se:Name>
<se:Description>
<se:Title>41 - 50</se:Title>
</se:Description>
<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
<ogc:PropertyIsEqualTo>
<ogc:PropertyName>rainfall</ogc:PropertyName>
<ogc:Literal>50</ogc:Literal>
</ogc:PropertyIsEqualTo>
</ogc:Filter>
<se:PolygonSymbolizer>
<se:Fill>
<se:SvgParameter name="fill">#c7e120</se:SvgParameter>
</se:Fill>
<se:Stroke>
<se:SvgParameter name="stroke">#232323</se:SvgParameter>
<se:SvgParameter name="stroke-width">1</se:SvgParameter>
<se:SvgParameter name="stroke-linejoin">bevel</se:SvgParameter>
</se:Stroke>
</se:PolygonSymbolizer>
</se:Rule>
<se:Rule>
<se:Name>> 50</se:Name>
<se:Description>
<se:Title>> 50</se:Title>
</se:Description>
<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
<ogc:PropertyIsEqualTo>
<ogc:PropertyName>rainfall</ogc:PropertyName>
<ogc:Literal>55</ogc:Literal>
</ogc:PropertyIsEqualTo>
</ogc:Filter>
<se:PolygonSymbolizer>
<se:Fill>
<se:SvgParameter name="fill">#e4e419</se:SvgParameter>
</se:Fill>
<se:Stroke>
<se:SvgParameter name="stroke">#232323</se:SvgParameter>
<se:SvgParameter name="stroke-width">1</se:SvgParameter>
<se:SvgParameter name="stroke-linejoin">bevel</se:SvgParameter>
</se:Stroke>
</se:PolygonSymbolizer>
</se:Rule>
</se:FeatureTypeStyle>
</UserStyle>
</NamedLayer>
</StyledLayerDescriptor>
How to rectify this error.
I am working on a color picker and I created a panel that mixes colors.
the first part of the panel you can create tint, tone and shades of a color and the second part you can use 2 colors to mix.
However I was faced with a weird situation where my gradient representation on the widget does not reflect the actual colors it is calculating.
Here you can see me using "GREEN" and "PINK" and the gradient is the same (RGB gradient?)
I achieved this by calculating the interpolation the top bar with RGB color space and on the second bar interpolating in HSV, and this is the result they actually give.
this is my comparation of my gradient tests(upper) with an actual color mixer(below) on the painting program that hosts my code, and it really displays it in HSV.
How do I achieve this gradient transition representation on my widget?
Code test:
def paintEvent(self, event):
green = QColor('#3c552c')
pink = QColor('#d9bdcf')
painter = QPainter(self)
painter.setPen(QPen(Qt.black, 4, Qt.SolidLine))
grad1 = QLinearGradient(20,20,190,20)
grad1.setColorAt(0.0, green)
grad1.setColorAt(1.0, pink)
painter.setBrush(QBrush(grad1))
painter.drawRect(10,10,200,200)
Code currently used:
def Mixer_Display(self):
# Display Color with Tint, Tone, Shade
mix_color_tint = str("background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgb(%f, %f, %f), stop:1 rgb(255, 255, 255));" % (self.color_n_red, self.color_n_green, self.color_n_blue))
self.layout.color_tint.setStyleSheet(mix_color_tint)
mix_color_tone = str("background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgb(%f, %f, %f), stop:1 rgb(127, 127, 127));" % (self.color_n_red, self.color_n_green, self.color_n_blue))
self.layout.color_tone.setStyleSheet(mix_color_tone)
mix_color_shade = str("background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgb(%f, %f, %f), stop:1 rgb(0, 0, 0));" % (self.color_n_red, self.color_n_green, self.color_n_blue))
self.layout.color_shade.setStyleSheet(mix_color_shade)
# Display Gradients
mix_gradient_1 = str("background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgb(%f, %f, %f), stop:1 rgb(%f, %f, %f));" % (self.color_l1_red, self.color_l1_green, self.color_l1_blue, self.color_r1_red, self.color_r1_green, self.color_r1_blue))
self.layout.gradient_1.setStyleSheet(mix_gradient_1)
mix_gradient_2 = str("background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgb(%f, %f, %f), stop:1 rgb(%f, %f, %f));" % (self.color_l2_red, self.color_l2_green, self.color_l2_blue, self.color_r2_red, self.color_r2_green, self.color_r2_blue))
self.layout.gradient_2.setStyleSheet(mix_gradient_2)
mix_gradient_3 = str("background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgb(%f, %f, %f), stop:1 rgb(%f, %f, %f));" % (self.color_l3_red, self.color_l3_green, self.color_l3_blue, self.color_r3_red, self.color_r3_green, self.color_r3_blue))
self.layout.gradient_3.setStyleSheet(mix_gradient_3)
You could mimic the HSV gradient by adding extra colors to the gradient. It looks like the addon uses a linear interpolation between the hue, saturation, and value of the two colors, so you could do something like
from PyQt5 import QtWidgets
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QColor, QPainter, QBrush, QLinearGradient, QPen
import numpy as np
class HSVColorBar(QtWidgets.QFrame):
def __init__(self, c0, c1, parent=None):
super().__init__(parent)
self.c0 = c0
self.c1 = c1
#staticmethod
def color_interpolator(col0, col1, factor):
h0 = col0.hsvHueF()
h1 = col1.hsvHueF()
h1 -= round(h1-h0)
hue = (h0*(1-factor) + h1*factor) % 1
sat = col0.hsvSaturationF() * (1 - factor) + col1.hsvSaturationF() * factor
val = col0.valueF() * (1 - factor) + col1.valueF() * factor
return QColor.fromHsvF(hue, sat, val)
def paintEvent(self, event):
painter = QPainter(self)
painter.setPen(QPen(Qt.black, 4, Qt.SolidLine))
grad1 = QLinearGradient(0, 0, event.rect().width(), 0)
# add intermediate colors to mimic hue mixing
for i in np.linspace(0, 1, 10):
grad1.setColorAt(i, self.color_interpolator(self.c0, self.c1, i))
painter.setBrush(QBrush(grad1))
painter.drawRect(event.rect())
if __name__ == "__main__":
app = QtWidgets.QApplication([])
green = QColor('#3c552c')
pink = QColor('#d9bdcf')
w = HSVColorBar(pink, green)
w.show()
app.exec()
Screenshot
inspired on your answer I did something like this.
main:
# HSV Gradients
mix_hsv_g1 = self.style.HSV_Gradient(self.layout.hsv_g1.width(), self.color_hsv_l1, self.color_hsv_r1)
self.layout.hsv_g1.setStyleSheet(str(mix_hsv_g1))
module:
def HSV_Gradient(self, width, color_left, color_right):
# Colors
left = [color_left[3], color_left[4], color_left[5]]
right = [color_right[3], color_right[4], color_right[5]]
# Conditions
cond1 = right[0] - left[0]
cond2 = (left[0] + 360) - right[0]
cond3 = right[2] - left[1]
cond4 = right[2] - left[2]
# Style String
slider_gradient = "background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, \n "
"stop:%s rgb(%s, %s, %s), " % (0.000, color_left[0], color_left[1], color_left[2])
unit = 1 / width
for i in range(width):
# Stop
stop = round((i * unit), 3)
# HSV Calculation
if cond1 <= cond2:
hue = left[0] + (stop * cond1)
else:
hue = left[0] - (stop * cond2)
if hue <= 0:
hue = hue + 360
else:
pass
hue = hue / 360
sat = (left[1] + (stop * cond3)) / 100
val = (left[2] + (stop * cond4)) / 100
# HSV to RGB Conversion
rgb = colorsys.hsv_to_rgb(hue, sat, val)
red = round(rgb[0]*255,3)
green = round(rgb[1]*255,3)
blue = round(rgb[2]*255,3)
# String
slider_gradient += "stop:%s rgb(%s, %s, %s), \n " % (stop, red, green, blue)
slider_gradient += "stop:%s rgb(%s, %s, %s) ) " % (1.000, color_right[0], color_right[1], color_right[2])
# Return StyleSheet String
return slider_gradient
Since I am using paint events to control a custom slider I thought in making a StyleSheet instead for the display since the calculation seems a bit long.
Result:
myDict={"pizzaHut" : ["PizzaHut", [155, 407], [1100, 2200], "halal", "fast-food", [10.00, 30.00], "Hawaiian Ala-Carte ($10.80)"],
"starbucks" : ["Starbucks Coffee", [155, 407], [700, 2200], "halal", "beverages", [6.00, 11.00], "Vanilla Latte ($6.70)"],
"subway" : ["Subway", [155, 407], [800, 2100], "halal", "fast-food", [5.00, 10.00], "Chicken Teriyaki Sandwich ($6.70)"]}
x = input("What is the x-coordinate of your location?")
y = input("What is the y-coordinate of your location?")
i want to find the distance of the different eateries from the location input by the user, how do i do that? Really new to python so i dont know how to start
datalist = list(myDict.values())
destinationList = []
for i in datalist:
destinationList.append([i[0],i[1]])
distance = []
def distance (x, y,destinationList):
for element in destinationList:
x1 = element[1][0]
y1 = element[1][1]
distance.append((((x1-x)**2)+((y1-y)**2))**0.5)
print(distance)
but this doesn't work.
The output should be a list of 3 calculated distance of user location from the 3 eateries
The complete code
myDict={"pizzaHut" : ["PizzaHut", [155, 407], [1100, 2200], "halal", "fast-food", [10.00, 30.00], "Hawaiian Ala-Carte ($10.80)"],
"starbucks" : ["Starbucks Coffee", [155, 407], [700, 2200], "halal", "beverages", [6.00, 11.00], "Vanilla Latte ($6.70)"],
"subway" : ["Subway", [155, 407], [800, 2100], "halal", "fast-food", [5.00, 10.00], "Chicken Teriyaki Sandwich ($6.70)"]}
x = int(input("What is the x-coordinate of your location?\n"))
y = int(input("What is the y-coordinate of your location?\n"))
datalist = list(myDict.values())
destinationList = []
for i in datalist:
destinationList.append([i[0],i[1]])
distance = []
def find_distance(x, y,destinationList):
for element in destinationList:
x1 = element[1][0]
y1 = element[1][1]
distance.append((((x1-x)**2)+((y1-y)**2))**0.5)
print(distance)
find_distance(x,y,destinationList)
This is my python script:
while True:
text = ""
img = cam.read()[1]
img = cv2.flip(img, 1)
imgHSV = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)
dst = cv2.calcBackProject([imgHSV], [0, 1], hist, [0, 180, 0, 256], 1)
disc = cv2.getStructuringElement(cv2.MORPH_ELLIPSE,(10,10))
cv2.filter2D(dst,-1,disc,dst)
blur = cv2.GaussianBlur(dst, (11,11), 0)
blur = cv2.medianBlur(blur, 15)
thresh = cv2.threshold(blur,0,255,cv2.THRESH_BINARY+cv2.THRESH_OTSU)[1]
thresh = cv2.merge((thresh,thresh,thresh))
thresh = cv2.cvtColor(thresh, cv2.COLOR_BGR2GRAY)
thresh = thresh[y:y+h, x:x+w]
contours = cv2.findContours(thresh.copy(), cv2.RETR_TREE, cv2.CHAIN_APPROX_NONE)[1]
if len(contours) > 0:
contour = max(contours, key = cv2.contourArea)
if cv2.contourArea(contour) > 10000:
x1, y1, w1, h1 = cv2.boundingRect(contour)
save_img = thresh[y1:y1+h1, x1:x1+w1]
This code works properly on another system but while I run it in my system,
it shows the following error:
cv2.error: OpenCV(4.0.0) /io/opencv/modules/imgproc/src/shapedescr.cpp:272: error: (-215:Assertion failed) npoints >= 0 && (depth == CV_32F || depth == CV_32S) in function 'contourArea'
Which can be caused by the following script:
contour = max(contours, key = cv2.contourArea)
I am using ubuntu 18.02 and opencv 4.0...
This is as part of our project, please help.
This problem is occurring because cv2.findContours has changed from V3.X to V4.0 in opencv.
So in V3.X it used to be
findContours(image, mode, method[, contours[, hierarchy[, offset]]]) -> image, contours, hierarchy
Three objects returned.
and V4.0
findContours(image, mode, method[, contours[, hierarchy[, offset]]]) -> contours, hierarchy
Two objects returned.
So you code would be
contours = cv2.findContours(thresh.copy(), cv2.RETR_TREE, cv2.CHAIN_APPROX_NONE)[0]
if you intend to get contours.
This is my code to paint a hollow cube using two squares . any better idea ?
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class CanvasUnit extends Canvas {
String SOutput;
public CanvasUnit(String TextToPrint) {
//SOutput = TextToPrint;
SOutput = "This is a hollow cube";
}
public void paint(Graphics g) {
int width = getWidth();
int height = getHeight();
int WLen = width / 4;
int HLen = height / 4;
int WPosA = (WLen * 2);
int HPosA = (HLen * 2);
int WPosB = (WPosA+WLen/2);
int HPosB = (HPosA+HLen/2);
//Clear the screen
g.setColor(0,0,0);
g.fillRect(0, 0, width, height);
g.setColor(255,255,255);
g.drawString(SOutput,0,0,Graphics.TOP|Graphics.LEFT);
//Object1
g.drawLine(WLen, HLen, WPosA, HLen);
g.drawLine(WLen, HLen, WLen, HPosA);
g.drawLine(WLen, HPosA, WPosA, HPosA);
g.drawLine(WPosA, HLen, WPosA, HPosA);
//--------------------------------------------
//Object2
g.drawLine(Ex(WLen), Ex(HLen), WPosB, Ex(HLen));
g.drawLine(Ex(WLen), Ex(HLen), Ex(WLen), HPosB);
g.drawLine(Ex(WLen), HPosB, WPosB, HPosB);
g.drawLine(WPosB, Ex(HLen), WPosB, HPosB);
//--------------------------------------------
//Connector Lines
g.drawLine(WLen, HLen, Ex(WLen), Ex(HLen));
g.drawLine(WPosA, HLen, WPosB, Ex(HLen));
g.drawLine(WLen, HPosA, Ex(WLen), HPosB);
g.drawLine(WPosA, HPosA, WPosB, HPosB);
}
private int Ex(int value){
return value + (value/2); }
}
Output :
Output : http://up.iranblog.com/images/ttfhinrbao6hvlkko8uk.png
Better way :
//Draw two hollow squares
g.drawRect(WLen, HLen, WLen, HLen);
g.drawRect(Ex(WLen), Ex(HLen), WLen, HLen);
//Connector Lines
g.drawLine(WLen, HLen, Ex(WLen), Ex(HLen));
g.drawLine(WPosA, HLen, WPosB, Ex(HLen));
g.drawLine(WLen, HPosA, Ex(WLen), HPosB);
g.drawLine(WPosA, HPosA, WPosB, HPosB);