how to increase size of a cell and keep it fixed in gnuplot - size

I have posted similar question 3 days ago ("increase pixel size"). However, so far, no answer. Therefore, I decided to start a new thread and make my question more precise.
I have 2D matrix 68 per 68 and I want to make a heat map from it. I did it, but
the problem is that for the matrix of this size cells become really small.
https://www.dropbox.com/s/b4ygdg0csa7d5y5/TEST_68x68.png?dl=0
Therefore, I want to increase size of a cell, for example twice and keep it fixed.
So, my idea was to define a matrix, which will be twice bigger than 68/68 that is 68*2/68*2 and then increase size of cell accordingly. I tried it: https://www.dropbox.com/s/spwo6zik1f077z3/TEST_incresedTwice.png?dl=0
However, dimensions of cells are also scaled. They have the same size like in the standard 68/68 matrix (see the first link). The cells also move. For example, instead of being bound to their original coordinates, all my values are moved by 10. I know why. The question is, how to prevent GNUPLOT from doing it?
Summarizing, I want to increase size of cells, keep their dimensions fixed and plot these bigger cells on a 68*2/68*2 matrix.
Any suggestions? Thank you.
Thank you.
Code below:
set terminal png transparent truecolor nocrop enhanced size 2000,2000 font
"arial bold,30”
set output 'TEST_now.png'
set size ratio 1
set palette rgbformulae -21,-22,-23
set xrange[-0.5:136.5]
set yrange[-0.5:136.5]
plot "matrix.dat" matrix using ($1*2):($2*2):3 with image not

With the image plotting style you get 68×68 pixels, all of the same size. You cannot increase the size of single pixels.
In your data file you have many entries with 0.00 which is what makes the white pixels. And, in the data file you have section like
0.000 0.457 0.000 0.000
0.000 0.000 0.000 0.000
0.000 0.073 0.337 0.000
0.002 0.993 0.916 0.000
0.000 0.003 0.000 0.000
and here I wouldn't even know how you would expect the pixels to be enlarged.
On possibility would be to plot every pixel as square point and use a large point size. This however leads to overlapping of immediately neighbouring points. To reduce this problem a bit, you could first draw all points with 0 < z <= 0.1, then those with 0.1 < z <= 0.2 and so on:
set terminal pngcairo transparent truecolor nocrop enhanced size 2000,2000 font "arial bold,30”
set output 'TEST_now.png'
set size ratio 1
set palette rgbformulae -21,-22,-23
set autoscale xfix
set autoscale yfix
set offsets 1,1,1,1
plot for [i=1:10] "matrix.dat" matrix using ($3 > 0.1*(i-1) && $3 <= 0.1*i ? $1 : 1/0):2:3 with points pt 5 ps 7 palette notitle
I don't know of any "smarter" solution, even when disregarding gnuplot's abilities.

Related

How to chart a line and a fixed point in the same chart in Looker

I want to compare precision-recall curve of my model to current rule based model precision-recall. So I want to have a chart with a line and a fixed point. Data looks like following:
threshold
precision
recall
current precision
current recall
0.01
0.05
0.93
. 0.55
. 0.35.
0.02
0.07
0.87
. 0.55
. 0.35.
0.03
0.09
0.81
. 0.55
. 0.35.
.
.
.
Please note current precision/current recall values are constant for each row.
I want to have a line (or scatter plot) of precision recall and mark the current precision/recall point in the same chart.
Is there a way to do this in Looker?
Go to the chart option under the "Series" tab (see pic 1), and for current precision/recall, change the type to scatter. For the remaining dimensions( precision and recall curve), change it to an area or line chart. Also, you can even go to the "Y" tab and drag current recall and precision to the right axis if you want. The final result should be similar to pic 2.

Relationship between dpi and figure size

I have created a figure using matplotlib but I have realized the plot axis and the drawn line gets zoomed out.
Reading this earlier discussion thread, it explains how to set the figure size.
fig, ax = plt.subplots()
fig.set_size_inches(3, 1.5)
plt.savefig(file.jpeg, edgecolor='black', dpi=400, facecolor='black', transparent=True)
With the above code (other configurations removed for brevity), I do get a resulting image file with 1200 X 600 desired dimensions(should we say resolution too?) and desired file size.
The projected image is scaled out in an unusual way, annotations for example are enlarged. While I can set the size of the labels on the axis, the figure doesn't look proportional with respect to the scale since the bottom and right spines are large and so are the plotted lines.
The question, therefore, is, what configurations are going wrong?
Figure size (figsize) determines the size of the figure in inches. This gives the amount of space the axes (and other elements) have inside the figure. The default figure size is (6.4, 4.8) inches in matplotlib 2. A larger figure size will allow for longer texts, more axes or more ticklabels to be shown.
Dots per inches (dpi) determines how many pixels the figure comprises. The default dpi in matplotlib is 100. A figure of figsize=(w,h) will have
px, py = w*dpi, h*dpi # pixels
# e.g.
# 6.4 inches * 100 dpi = 640 pixels
So in order to obtain a figure with a pixel size of e.g. (1200,600) you may chose several combinations of figure size and dpi, e.g.
figsize=(15,7.5), dpi= 80
figsize=(12,6) , dpi=100
figsize=( 8,4) , dpi=150
figsize=( 6,3) , dpi=200
etc.
Now, what is the difference? This is determined by the size of the elements inside the figure. Most elements like lines, markers, texts have a size given in points.
Matplotlib figures use Points per inch (ppi) of 72. A line with thickness 1 point will be 1./72. inch wide. A text with fontsize 12 points will be 12./72. inch heigh.
Of course if you change the figure size in inches, points will not change, so a larger figure in inches still has the same size of the elements. Changing the figure size is thus like taking a piece of paper of a different size. Doing so, would of course not change the width of the line drawn with the same pen.
On the other hand, changing the dpi scales those elements. At 72 dpi, a line of 1 point size is one pixel strong. At 144 dpi, this line is 2 pixels strong. A larger dpi will therefore act like a magnifying glass. All elements are scaled by the magnifying power of the lens.
A comparisson for constant figure size and varying dpi is shown in the image below on the left. On the right you see a constant dpi and varying figure size. Figures in each row have the same pixel size.
Code to reproduce:
import matplotlib.pyplot as plt
%matplotlib inline
def plot(fs,dpi):
fig, ax=plt.subplots(figsize=fs, dpi=dpi)
ax.set_title("Figsize: {}, dpi: {}".format(fs,dpi))
ax.plot([2,4,1,5], label="Label")
ax.legend()
figsize=(2,2)
for i in range(1,4):
plot(figsize, i*72)
dpi=72
for i in [2,4,6]:
plot((i,i), dpi)

GNURadio - WX FFT Plot not showing frequency on the x axis

I'm using WX GUI FFT to display a specific frequency range (38Hz for IR). I can't seem to get the plot to show the frequency range on the x axis. I have it set up like follows:
And here's what it looks like when it runs:
As can be seen there's no frequency range on the x axis.
Any idea what I'm doing wrong?
The display is absolutely correct.
You set the sampling rate, and hence the bandwidth to be displayed, to be nominally 10 MHz, so each of the ten divisions of the x-Axis should be 1 MHz wide.
Now, your center frequency is in fact of course not 0 MHz, but 38 kHz, but WX GUI rounds the numbers for display – it's really not that useful to see "0.038 MHz" as an axis label.
More importantly, you seem to be confused about what the sampling rate and what the center frequency are supposed to be; my gut feeling is that you want to observe an 38 kHz wide channel around 10 MHz. What you do is observe 10 MHz around 38 kHz (which, physically, doesn't make much sense, and you should see very clear warnings about that in the console).
Furthermore, WX is going away with the next release of GNU Radio. Use the Qt GUI instead.

Incorrect Hue returned by getHue function

I am converting RGB to HSV using built in function of UIColour: - (BOOL)getHue:(CGFloat *)hue saturation:(CGFloat *)saturation brightness:(CGFloat *)brightness alpha:(CGFloat *)alpha but for some RGB it is not giving correct output.
CGFloat h,s,v,a;
UIColor *tColor=[UIColor colorWithRed:(230.0/255.0) green:(226.0/255.0) blue:(226.0/255.0) alpha:1.0];
BOOL success=[tColor getHue:&h saturation:&s brightness:&v alpha:&a];
NSLog(#"Output-> Success:%d, hue:%f, sat:%f, value:%f, alpha:%f",success,h,s,v,a);
Actual output:
Output-> Success:1, hue:1.000000, sat:0.017391, value:0.901961, alpha:1.000000
Expected output:
hue:0, sat:0.017391, value:0.901961, alpha:1.000000
Note: I have derived this expected output from some online conversion tools(ex: http://www.rapidtables.com/convert/color/rgb-to-hsv.htm)
You can see clearly difference in Hue? So, why such difference in Hue and how can I get my expected output?
While most of the rest of the world defines "hue" as going from 0 to 360 degrees, for UIColor it's 0.0 to 1.0.
Actually, just as 360.000 degrees is identical to 0.000 in geometry or someone else's hue, so we have with UIColor's hue that 1.000 is identical to 0.000 (hallucinate as many zero digits after the decimal point as you like, and in binary if you prefer.)
So, your "actual output" and "expected output" are identical. In coding, keep hue in the range 0.000 to 0.999, and change 1.000 to 0.000 to avoid trouble.
Hue in HSB or HSL is measured as degrees around a colour circle, starting with red at 0° and wrapping back around to red at 360°; so a hue of 0° is the same as a hue of 360°. UIColor maps this range (0–360°) to the values 0–1 (0°=0.0, 360°=1.0).

Make the X and Y axis scales equal on an Excel chart

I'd like the X and Y axes of my Excel charts to have the same scale on the screen, because I'm plotting geographical data. A 1km by 1km square should look like a square, not like a rectangle, i.e. no squishing of the map in one or the other direction. In Matlab, the command that would do this is axis equal.
How do I do this using VBA?
Am I overlooking an even simpler solution directly in Excel?
In addition to guitarthrower's answer you will need to do the following:
Select the 'Plot Area' of the chart and then manually set the height and width of the plot area.
Sheets("Chart1").PlotArea.Select
Selection.Height = 500
Selection.Width = 500
Just setting the axis min and max values will still allow the chart to be 'squished'.
When you select the plot area and write Selection.Width = something, the Width value you are setting also includes the width of the axis labels/text. This may not be what you want.
Instead, you can set the INSIDE Width/Height value using
Selection.InsideHeight = 250
Selection.InsideWidth = 250
Another method similar to Stewbob's is to set the limits to some ratio of each other (my plots are 4 times as wide as they are tall) and then use the height to set the width.
ActiveChart.PlotArea.Select
Selection.Width = Selection.Height * 4