I have the following requirement and wondering if I could solve it with Julia: draw a SVG plot with up to 4 curves on it. Each curve has to be constructed out of 6 data points.
The plot title and the legend should be positioned on the top right corner outside of the plot area.
So far so easy, I'm pretty certain it's solvable with one of the great Julia metapackages. But this one drives me crazy:
In the bottom right corner outside of the plot area a table should be drawn. It should contain the values of 6 data points of each curve.
Example:
| pressure | 1 | 2 | 3 | 4 | 5 | 6 |
|----------------|-----|-----|-----|-----|-----|------|
| colored line 1 | 3.8 | 3.9 | 4.1 | 5.0 | 9.1 | 10.0 |
| colored line 2 | 4.0 | 4.1 | 5.0 | 7.1 | 8.0 | 11.0 |
| gal/min | | | | | | |
The plot and the data table should be placed both inside the SVG.
After studying the documentation for hours I'm still clueless how to draw this table. Is this even possible with a plotting library?
Related
I am trying to create a postgresql database to store the performance specifications of wind turbines and their characteristics.
The way I have structures this in my head is the following:
A main table with a unique id for each turbine model as well as basic information about them (rotor size, max power, height, manufacturer, model id, design date, etc.)
example structure of the "main" table holding all of the main turbine characteristics
turbine_model
rotor_size
height
max_power
etc.
model_x1
200
120
15
etc.
model_b7
250
145
18
etc.
A lookup table for each turbine model storing how much each produces for a given wind speed, with one column for wind speeds and another row for power output. There will be as many of these tables as there are rows in the main table.
example table "model_x1":
wind_speed
power_output
1
0.5
2
1.5
3
2.0
4
2.7
5
3.2
6
3.9
7
4.9
8
7.0
9
10.0
However, I am struggling to find a way to implement this as I cannot find a way to build relationships between each row of the "main" table and the lookup tables. I am starting to think this approach is not suited for a relational database.
How would you design a database to solve this problem?
A relational database is perfect for this, but you will want to learn a little bit about normalization to design the layout of the tables.
Basically, you'll want to add a 3rd column to your poweroutput reference table so that each model is just more rows (grow long, not wide).
Here is an example of what I mean, but I even took this to a further extreme where you might want to have a reference for other metrics in addition to windspeed (rpm in this case) so you can see what I mean.
PowerOutput Reference Table
+----------+--------+------------+-------------+
| model_id | metric | metric_val | poweroutput |
+----------+--------+------------+-------------+
| model_x1 | wind | 1 | 0.5 |
| model_x1 | wind | 2 | 1.5 |
| model_x1 | wind | 3 | 3 |
| ... | ... | ... | ... |
| model_x1 | rpm | 1250 | 1.5 |
| model_x1 | rpm | 1350 | 2.5 |
| model_x1 | rpm | 1450 | 3.5 |
| ... | ... | ... | ... |
| model_bg | wind | 1 | 0.7 |
| model_bg | wind | 2 | 0.9 |
| model_bg | wind | 3 | 1.2 |
| ... | ... | ... | ... |
| model_bg | rpm | 1250 | 1 |
| model_bg | rpm | 1350 | 1.5 |
| model_bg | rpm | 1450 | 2 |
+----------+--------+------------+-------------+
The problem: I have two dataframes - one with a bunch of product titles that are not normalized, and one with a bunch of regular expressions that are tied to normalized product titles. I need to match the non-normalized titles to some regular expressions which are tied to normalized titles.
It should make more sense with the sample data below.
First dataframe (raw_titles):
| | Title | Release Date |
|---|------------------------------------------------|--------------|
| 1 | Apple iPad Air (3rd generation) - 64GB | 01/01/20 |
| 2 | Philips Hue White Ambiance A19 LED Smart Bulbs | 08/12/20 |
| 3 | Powerbeats Pro Totally Wireless Earphones | 06/20/19 |
Second dataframe (regex_titles):
| | Regex | Manufacturer | Model |
|---|-------------------------------------------------------|--------------|-------------------------|
| 1 | /ipad\s?air(?=.*(\b3\b|3rd\s?gen|2019))|\bair\s?3\b/i | Apple | iPad Air (2019) |
| 2 | /hue(?=.*cher)/i | Philips | Hue White Ambiance Cher |
| 3 | /powerbeats\s?pro/i | Beats | Powerbeats Pro |
The idea is to take each title in raw_titles, and run it through all the values in regex_titles to see if there's a match. Once that's done, raw_titles should then have two additional columns, Manufacturer and Model, which correspond to the regex_titles series they matched to (if there was no match, it would just stay empty.
Then the final table would look like this:
| | Title | Release Date | Manufacturer | Model |
|---|------------------------------------------------|--------------|--------------|-----------------|
| 1 | Apple iPad Air (3rd generation) - 64GB | 01/01/20 | Apple | iPad Air (2019) |
| 2 | Philips Hue White Ambiance A19 LED Smart Bulbs | 08/12/20 | | |
| 3 | Powerbeats Pro Totally Wireless Earphones | 06/12/19 | Beats | Powerbeats Pro |
There are many ways to do this, but the simplest is to test each of the regexes on each of the titles and return the first match you find. First, we'll define a function that will return two values: the manufacturer and model of the regex row, if we match, two Nones otherwise:
def find_match(title_row):
for _, regex_row in regex_titles.iterrows():
if re.search(regex_row['Regex'], title_row['Title']):
return [regex_row['Manufacturer'], regex_row['Model']]
return [None, None]
Then we'll apply our function to our titles dataframe and save the output to two new columns, Manufacturer and Model:
raw_titles[['Manufacturer', 'Model']] = raw_titles.apply(find_match, axis=1, result_type='broadcast')
Title Release Date Manufacturer Model
0 Apple iPad Air (3rd generation) - 64GB 01/01/20 Apple iPad Air (2019)
1 Philips Hue White Ambiance A19 LED Smart Bulbs 08/12/20 None None
2 Powerbeats Pro Totally Wireless Earphones 06/20/19 Beats Powerbeats Pro
One complication is that you'll have to translate your perl regexes into the python regex format:
perl: /powerbeats\s?pro/i -> python: (?i)powerbeats\s?pro
They're mostly the same, with a few small differences. Here's the reference.
Background and objective
I have data that is organised as follows:
|---------------------|------------------|---------------------|------------------|
| Place | Time_Car | Time_Jet | Time_Heli
| | | |
|---------------------|------------------|---------------------|------------------|
| LocX | 34 | 12 | 14 |
|---------------------|------------------|---------------------|------------------|
| LocY | 24 | 8 | 10 |
|---------------------|------------------|---------------------|------------------|
In Tableau, I want to be able to plot the average of the maximum times for each Destination column, for each type of transport.
So,
For Time_heli, the maximum time to LocX is 8 (out of 7 and 8)
The maximum time to LocY is 5
The average of those two is 6.5
This produces something this after repeating for Time_car and Time_jet:
I am using Tableau 10.5.4 version on Windows 8
Approach
To do, I will get the maximum times for each Place by creating a new field for each type of transport with:
{FIXED Place,Option: MAX([Time_Car])}
{FIXED Place,Option: MAX([Time_Jet])}
{FIXED Place,Option: MAX([Time_Heli])}
However, this won't allow me plot the data in one chart on Tableau.
How can I achieve the chart above?
I am trying to define conditional formatting on a bar chart in excel based on the value of the data point or his legend.
I want to make it dynamic.
Let's suppose that I have the following chart
3 Alex
4 John
6 David
I want to color the bar ABOVE "John" in red.
Any ideas ?
Thanks
Jon Peltier has a great article showing how you can do this: https://peltiertech.com/conditional-formatting-of-excel-charts/
In essence, just use two different series with data like so:
| A | B | C |
-------------------
1 | Alex | 3 | |
2 | John | | 4 |
3 | David | 6 | |
So you plot a bar chart with 2 series, the first using column B and the second (red) using column C. If you have some rule that decides who should be red, then just use =IF() instead of hard coding the numbers
I'm using this command to merge PDFs 2x1
gm montage -mode concatenate -rotate 90 -tile 2x1 ${labels.join(" ")} ${out}
The problem, is if there are 5 PDFs, then the 1 is in the center. Is there anyway to get this where the last one, or an uneven one is left aligned, and not center aligned?
The result right now
Page 1
| || |
| || |
| || |
Page 2
| |
| |
| |
The desired result for page 2
| |
| |
| |
Thanks!
So far the only thing i've found to work is to detect if there are an odd number of images, if so, add one more image the same size as the others. The "one more" is just a blank white image.